Add default baseType to the substitution type
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / impl / ElementBusinessLogic.java
index 91d7fa6..176cded 100644 (file)
  * Modifications copyright (c) 2019 Nokia
  * ================================================================================
  */
-
 package org.openecomp.sdc.be.components.impl;
 
+import static org.apache.commons.lang.BooleanUtils.isTrue;
+import static org.openecomp.sdc.be.components.impl.ImportUtils.Constants.DEFAULT_ICON;
+
 import fj.data.Either;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.utils.URLEncodedUtils;
 import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
 import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.config.Configuration;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
@@ -40,19 +58,42 @@ import org.openecomp.sdc.be.datamodel.api.CategoryTypeEnum;
 import org.openecomp.sdc.be.datamodel.utils.NodeTypeConvertUtils;
 import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
 import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.*;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
+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.GraphPropertyEnum;
+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.model.ArtifactType;
+import org.openecomp.sdc.be.model.BaseType;
+import org.openecomp.sdc.be.model.CatalogUpdateTimestamp;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DistributionStatusEnum;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Product;
+import org.openecomp.sdc.be.model.PropertyScope;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.Tag;
+import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.model.catalog.CatalogComponent;
 import org.openecomp.sdc.be.model.category.CategoryDefinition;
 import org.openecomp.sdc.be.model.category.GroupingDefinition;
 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
 import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
 import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
 import org.openecomp.sdc.be.resources.data.category.CategoryData;
 import org.openecomp.sdc.be.resources.data.category.SubCategoryData;
@@ -63,13 +104,7 @@ import org.openecomp.sdc.common.datastructure.Wrapper;
 import org.openecomp.sdc.common.log.wrappers.Logger;
 import org.openecomp.sdc.common.util.ValidationUtils;
 import org.openecomp.sdc.exception.ResponseFormat;
-
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-
-import static org.apache.commons.lang.BooleanUtils.isTrue;
+import org.springframework.beans.factory.annotation.Autowired;
 
 @org.springframework.stereotype.Component("elementsBusinessLogic")
 public class ElementBusinessLogic extends BaseBusinessLogic {
@@ -80,15 +115,19 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
     private static final String VALIDATION_OF_USER_FAILED_USER_ID = "Validation of user failed, userId {}";
     private static final String COMPONENT_TYPE_IS_INVALID = "Component type {} is invalid";
     private static final String VALIDATION_OF_USER_ROLE_FAILED_USER_ID = "Validation of user role failed, userId {}";
-
-    @javax.annotation.Resource
-    private IElementOperation elementOperation;
-
-    @javax.annotation.Resource
-    private UserBusinessLogic userAdminManager;
+    private final IElementOperation elementOperation;
+
+    @Autowired
+    public ElementBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, IGroupInstanceOperation groupInstanceOperation,
+                                IGroupTypeOperation groupTypeOperation, GroupBusinessLogic groupBusinessLogic, InterfaceOperation interfaceOperation,
+                                InterfaceLifecycleOperation interfaceLifecycleTypeOperation, ArtifactsOperations artifactToscaOperation,
+                                IElementOperation elementOperation, UserBusinessLogic userAdminManager) {
+        super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation,
+            artifactToscaOperation);
+        this.elementOperation = elementOperation;
+    }
 
     /**
-     *
      * @param user
      * @return
      */
@@ -99,47 +138,29 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         String role = user.getRole();
         String userId = user.getUserId();
         Role currentRole = Role.valueOf(role);
-
         switch (currentRole) {
             case DESIGNER:
                 response = handleDesigner(userId);
                 break;
-
-            case TESTER:
-                response = handleTester();
-                break;
-
-            case GOVERNOR:
-                response = handleGovernor();
-                break;
-
-            case OPS:
-                response = handleOps();
-                break;
-
             case PRODUCT_STRATEGIST:
                 response = handleProductStrategist();
                 break;
-
             case PRODUCT_MANAGER:
                 response = handleProductManager(userId);
                 break;
-
             case ADMIN:
                 response = handleAdmin();
                 break;
-
             default:
                 response = Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
                 break;
         }
         // converting the Set to List so the rest of the code will handle it normally (Was changed because the same element with the same uuid was returned twice)
         return convertedToListResponse(response);
-
     }
 
-    private Either<Map<String, List<? extends Component>>, ResponseFormat> convertedToListResponse(Either<Map<String, Set<? extends Component>>, ResponseFormat> setResponse) {
-
+    private Either<Map<String, List<? extends Component>>, ResponseFormat> convertedToListResponse(
+        Either<Map<String, Set<? extends Component>>, ResponseFormat> setResponse) {
         Map<String, List<? extends Component>> arrayResponse = new HashMap<>();
         if (setResponse.isLeft()) {
             for (Map.Entry<String, Set<? extends Component>> entry : setResponse.left().value().entrySet()) {
@@ -154,9 +175,8 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         Either<Map<String, Set<? extends Component>>, ResponseFormat> response;
         // userId should stay null
         Set<LifecycleStateEnum> lifecycleStates = new HashSet<>();
-        Set<LifecycleStateEnum> lastStateStates = new HashSet<>();
         lifecycleStates.add(LifecycleStateEnum.CERTIFIED);
-        response = getFollowedResourcesAndServices(null, lifecycleStates, lastStateStates);
+        response = getFollowedResourcesAndServices(null, lifecycleStates, new HashSet<>());
         return response;
     }
 
@@ -166,19 +186,13 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         Either<Map<String, Set<? extends Component>>, ResponseFormat> response;
         lifecycleStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
         lifecycleStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-        lifecycleStates.add(LifecycleStateEnum.READY_FOR_CERTIFICATION);
-        lifecycleStates.add(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
         lifecycleStates.add(LifecycleStateEnum.CERTIFIED);
         // more states
-        lastStateStates.add(LifecycleStateEnum.READY_FOR_CERTIFICATION);
+        lastStateStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
         response = getFollowedResourcesAndServices(userId, lifecycleStates, lastStateStates);
         return response;
     }
 
-    private Either<Map<String, Set<? extends Component>>, ResponseFormat> handleGovernor() {
-        return handleFollowedCertifiedServices(null);
-    }
-
     private Either<Map<String, Set<? extends Component>>, ResponseFormat> handleProductStrategist() {
         // Should be empty list according to Ella, 13/03/16
         Map<String, Set<? extends Component>> result = new HashMap<>();
@@ -192,52 +206,22 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         Either<Map<String, Set<? extends Component>>, ResponseFormat> response;
         lifecycleStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
         lifecycleStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-        lifecycleStates.add(LifecycleStateEnum.READY_FOR_CERTIFICATION);
-        lifecycleStates.add(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
         lifecycleStates.add(LifecycleStateEnum.CERTIFIED);
         // more states
-        lastStateStates.add(LifecycleStateEnum.READY_FOR_CERTIFICATION);
+        lastStateStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
         response = getFollowedProducts(userId, lifecycleStates, lastStateStates);
         return response;
     }
 
-    private Either<Map<String, Set<? extends Component>>, ResponseFormat> handleOps() {
-        Set<DistributionStatusEnum> distStatus = new HashSet<>();
-        distStatus.add(DistributionStatusEnum.DISTRIBUTION_APPROVED);
-        distStatus.add(DistributionStatusEnum.DISTRIBUTED);
-
-        return handleFollowedCertifiedServices(distStatus);
-    }
-
-    private Either<Map<String, Set<? extends Component>>, ResponseFormat> handleFollowedCertifiedServices(Set<DistributionStatusEnum> distStatus) {
-
-        Either<List<Service>, StorageOperationStatus> services = toscaOperationFacade.getCertifiedServicesWithDistStatus(distStatus);
-        if (services.isLeft()) {
-            Map<String, Set<? extends Component>> result = new HashMap<>();
-            Set<Service> set = new HashSet<>();
-            set.addAll(services.left().value());
-            result.put(SERVICES, set);
-            return Either.left(result);
-        } else {
-            return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(services.right().value())));
-        }
-    }
-
-    private Either<Map<String, Set<? extends Component>>, ResponseFormat> handleTester() {
-        Set<LifecycleStateEnum> lifecycleStates = new HashSet<>();
-        lifecycleStates.add(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
-        lifecycleStates.add(LifecycleStateEnum.READY_FOR_CERTIFICATION);
-
-        return getFollowedResourcesAndServices(null, lifecycleStates, null);
-    }
-
-    private Either<Map<String, Set<? extends Component>>, ResponseFormat> getFollowedResourcesAndServices(String userId, Set<LifecycleStateEnum> lifecycleStates, Set<LifecycleStateEnum> lastStateStates) {
-
+    private Either<Map<String, Set<? extends Component>>, ResponseFormat> getFollowedResourcesAndServices(String userId,
+                                                                                                          Set<LifecycleStateEnum> lifecycleStates,
+                                                                                                          Set<LifecycleStateEnum> lastStateStates) {
         try {
-            Either<Set<Resource>, StorageOperationStatus> resources = toscaOperationFacade.getFollowed(userId, lifecycleStates, lastStateStates, ComponentTypeEnum.RESOURCE);
-
+            Either<Set<Resource>, StorageOperationStatus> resources = toscaOperationFacade
+                .getFollowed(userId, lifecycleStates, lastStateStates, ComponentTypeEnum.RESOURCE);
             if (resources.isLeft()) {
-                Either<Set<Service>, StorageOperationStatus> services = toscaOperationFacade.getFollowed(userId, lifecycleStates, lastStateStates, ComponentTypeEnum.SERVICE);
+                Either<Set<Service>, StorageOperationStatus> services = toscaOperationFacade
+                    .getFollowed(userId, lifecycleStates, lastStateStates, ComponentTypeEnum.SERVICE);
                 if (services.isLeft()) {
                     Map<String, Set<? extends Component>> result = new HashMap<>();
                     result.put(SERVICES, services.left().value());
@@ -254,8 +238,10 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         }
     }
 
-    private Either<Map<String, Set<? extends Component>>, ResponseFormat> getFollowedProducts(String userId, Set<LifecycleStateEnum> lifecycleStates, Set<LifecycleStateEnum> lastStateStates) {
-        Either<Set<Product>, StorageOperationStatus> products = toscaOperationFacade.getFollowed(userId, lifecycleStates, lastStateStates, ComponentTypeEnum.PRODUCT);
+    private Either<Map<String, Set<? extends Component>>, ResponseFormat> getFollowedProducts(String userId, Set<LifecycleStateEnum> lifecycleStates,
+                                                                                              Set<LifecycleStateEnum> lastStateStates) {
+        Either<Set<Product>, StorageOperationStatus> products = toscaOperationFacade
+            .getFollowed(userId, lifecycleStates, lastStateStates, ComponentTypeEnum.PRODUCT);
         if (products.isLeft()) {
             Map<String, Set<? extends Component>> result = new HashMap<>();
             result.put("products", products.left().value());
@@ -277,33 +263,17 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
     }
 
     public Either<CategoryDefinition, ResponseFormat> createCategory(CategoryDefinition category, String componentTypeParamName, String userId) {
-
         AuditingActionEnum auditingAction = AuditingActionEnum.ADD_CATEGORY;
         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentTypeParamName);
         String componentType = componentTypeEnum == null ? componentTypeParamName : componentTypeEnum.getValue();
         CategoryTypeEnum categoryType = CategoryTypeEnum.CATEGORY;
-
-        User user;
-        Either<User, ResponseFormat> validateUser = validateUser(userId);
-        if (validateUser.isRight()) {
-            log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
-            ResponseFormat responseFormat = validateUser.right().value();
-            user = new User();
-            user.setUserId(userId);
-            String currCategoryName = (category == null ? null : category.getName());
-            handleCategoryAuditing(responseFormat, user, currCategoryName, auditingAction, componentType);
-            return Either.right(responseFormat);
-        }
-
-        user = validateUser.left().value();
-
+        User user = validateUserExists(userId);
         if (category == null) {
             log.debug("Category json is invalid");
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
             handleCategoryAuditing(responseFormat, user, null, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         String categoryName = category.getName();
         // For auditing of failures we need the original non-normalized name
         String origCategoryName = categoryName;
@@ -313,7 +283,6 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, origCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Either<Boolean, ResponseFormat> validateUserRole = validateUserRole(user, componentTypeEnum);
         if (validateUserRole.isRight()) {
             log.debug(VALIDATION_OF_USER_ROLE_FAILED_USER_ID, userId);
@@ -321,30 +290,30 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, origCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         if (!ValidationUtils.validateCategoryDisplayNameFormat(categoryName)) {
             log.debug("Category display name format is invalid, name {}, componentType {}", categoryName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, componentType, categoryType.getValue());
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, componentType, categoryType.getValue());
             handleCategoryAuditing(responseFormat, user, origCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         categoryName = ValidationUtils.normalizeCategoryName4Display(categoryName);
-
         if (!ValidationUtils.validateCategoryDisplayNameLength(categoryName)) {
-            log.debug("Category display name length is invalid, should be from 4 to 25 chars, name {}, componentType {}", categoryName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, componentType, categoryType.getValue());
+            log.debug("Category display name length is invalid, should be from 4 to 25 chars, name {}, componentType {}", categoryName,
+                componentType);
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, componentType, categoryType.getValue());
             handleCategoryAuditing(responseFormat, user, origCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         category.setName(categoryName);
-
         String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(categoryName);
         category.setNormalizedName(normalizedName);
-
+        if (ValidationUtils.validateCategoryIconNotEmpty(category.getIcons())) {
+            log.debug("createCategory: setting category icon to default icon since service category was created without an icon ");
+            category.setIcons(Arrays.asList(DEFAULT_ICON));
+        }
         NodeTypeEnum nodeType = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, categoryType);
-
         Either<Boolean, ActionStatus> categoryUniqueEither = elementOperation.isCategoryUniqueForType(nodeType, normalizedName);
         if (categoryUniqueEither.isRight()) {
             log.debug("Failed to check category uniqueness, name {}, componentType {}", categoryName, componentType);
@@ -352,19 +321,19 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, origCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Boolean isCategoryUnique = categoryUniqueEither.left().value();
-        if (!isCategoryUnique) {
+        if (Boolean.FALSE.equals(isCategoryUnique)) {
             log.debug("Category is not unique, name {}, componentType {}", categoryName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, componentType, categoryName);
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, componentType, categoryName);
             handleCategoryAuditing(responseFormat, user, origCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Either<CategoryDefinition, ActionStatus> createCategoryByType = elementOperation.createCategory(category, nodeType);
         if (createCategoryByType.isRight()) {
             log.debug("Failed to create category, name {}, componentType {}", categoryName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, componentType, categoryName);
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, componentType, categoryName);
             handleCategoryAuditing(responseFormat, user, origCategoryName, auditingAction, componentType);
             return Either.right(componentsUtils.getResponseFormat(createCategoryByType.right().value()));
         }
@@ -375,37 +344,33 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(category);
     }
 
-    public Either<SubCategoryDefinition, ResponseFormat> createSubCategory(SubCategoryDefinition subCategory, String componentTypeParamName, String parentCategoryId, String userId) {
-
+    public Either<SubCategoryDefinition, ResponseFormat> createSubCategory(SubCategoryDefinition subCategory, String componentTypeParamName,
+                                                                           String parentCategoryId, String userId) {
         AuditingActionEnum auditingAction = AuditingActionEnum.ADD_SUB_CATEGORY;
         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentTypeParamName);
         String componentType = componentTypeEnum == null ? componentTypeParamName : componentTypeEnum.getValue();
         CategoryTypeEnum categoryType = CategoryTypeEnum.SUBCATEGORY;
         // For auditing
         String parentCategoryName = parentCategoryId;
-
         if (subCategory == null) {
             log.debug("Sub-category json is invalid");
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
             handleCategoryAuditing(responseFormat, null, parentCategoryName, null, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         String subCategoryName = subCategory.getName();
         // For auditing of failures we need the original non-normalized name
         String origSubCategoryName = subCategoryName;
         User user;
-        try{
-            user =  validateUserExists(userId, "createSubCategory", false);
-        } catch(ByActionStatusComponentException e){
+        try {
+            user = validateUserExists(userId);
+        } catch (ByActionStatusComponentException e) {
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
-            handleComponentException(userId, auditingAction, componentType, parentCategoryName, origSubCategoryName,
-                responseFormat);
+            handleComponentException(userId, auditingAction, componentType, parentCategoryName, origSubCategoryName, responseFormat);
             throw e;
-        } catch(ByResponseFormatComponentException e){
+        } catch (ByResponseFormatComponentException e) {
             ResponseFormat responseFormat = e.getResponseFormat();
-            handleComponentException(userId, auditingAction, componentType, parentCategoryName, origSubCategoryName,
-                responseFormat);
+            handleComponentException(userId, auditingAction, componentType, parentCategoryName, origSubCategoryName, responseFormat);
             throw e;
         }
         if (componentTypeEnum == null) {
@@ -414,7 +379,6 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Either<Boolean, ResponseFormat> validateComponentType = validateComponentTypeForCategory(componentTypeEnum, categoryType);
         if (validateComponentType.isRight()) {
             log.debug("Validation of component type for sub-category failed");
@@ -422,7 +386,6 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Either<Boolean, ResponseFormat> validateUserRole = validateUserRole(user, componentTypeEnum);
         if (validateUserRole.isRight()) {
             log.debug(VALIDATION_OF_USER_ROLE_FAILED_USER_ID, userId);
@@ -430,65 +393,69 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         NodeTypeEnum parentNodeType = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.CATEGORY);
         NodeTypeEnum childNodeType = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.SUBCATEGORY);
-
         CategoryDefinition categoryDefinition;
-        Either<CategoryDefinition, ResponseFormat> validateCategoryExists = validateCategoryExists(parentNodeType, parentCategoryId, componentTypeEnum);
+        Either<CategoryDefinition, ResponseFormat> validateCategoryExists = validateCategoryExists(parentNodeType, parentCategoryId,
+            componentTypeEnum);
         if (validateCategoryExists.isRight()) {
             log.debug("Validation of parent category exists failed, parent categoryId {}", parentCategoryId);
             ResponseFormat responseFormat = validateCategoryExists.right().value();
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         categoryDefinition = validateCategoryExists.left().value();
         parentCategoryName = categoryDefinition.getName();
-
         if (!ValidationUtils.validateCategoryDisplayNameFormat(subCategoryName)) {
             log.debug("Sub-category display name format is invalid, name {}, componentType {}", subCategoryName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, componentType, categoryType.getValue());
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, componentType, categoryType.getValue());
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         subCategoryName = ValidationUtils.normalizeCategoryName4Display(subCategoryName);
-
         if (!ValidationUtils.validateCategoryDisplayNameLength(subCategoryName)) {
-            log.debug("Sub-category display name length is invalid, should be from 4 to 25 chars, name {}, componentType {}", subCategoryName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, componentType, categoryType.getValue());
+            log.debug("Sub-category display name length is invalid, should be from 4 to 25 chars, name {}, componentType {}", subCategoryName,
+                componentType);
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, componentType, categoryType.getValue());
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(subCategoryName);
         subCategory.setNormalizedName(normalizedName);
-
         // Uniqueness under this category
-        Either<Boolean, ActionStatus> subCategoryUniqueForCategory = elementOperation.isSubCategoryUniqueForCategory(childNodeType, normalizedName, parentCategoryId);
+        Either<Boolean, ActionStatus> subCategoryUniqueForCategory = elementOperation
+            .isSubCategoryUniqueForCategory(childNodeType, normalizedName, parentCategoryId);
         if (subCategoryUniqueForCategory.isRight()) {
-            log.debug("Failed to check sub-category uniqueness, parent name {}, subcategory norm name {}, componentType {}", parentCategoryName, normalizedName, componentType);
+            log.debug("Failed to check sub-category uniqueness, parent name {}, subcategory norm name {}, componentType {}", parentCategoryName,
+                normalizedName, componentType);
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(subCategoryUniqueForCategory.right().value());
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Boolean isSubUnique = subCategoryUniqueForCategory.left().value();
-        if (!isSubUnique) {
-            log.debug("Sub-category is not unique for category, parent name {}, subcategory norm name {}, componentType {}", parentCategoryName, normalizedName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY, componentType, subCategoryName, parentCategoryName);
+        if (Boolean.FALSE.equals(isSubUnique)) {
+            log.debug("Sub-category is not unique for category, parent name {}, subcategory norm name {}, componentType {}", parentCategoryName,
+                normalizedName, componentType);
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY, componentType, subCategoryName, parentCategoryName);
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         // Setting name of subcategory to fit the similar subcategory name
+
         // ignoring cases.
+
         // For example if Network-->kUKU exists for service category Network,
+
         // and user is trying to create Router-->Kuku for service category
+
         // Router,
+
         // his subcategory name will be Router-->kUKU.
-        Either<SubCategoryDefinition, ActionStatus> subCategoryUniqueForType = elementOperation.getSubCategoryUniqueForType(childNodeType, normalizedName);
+        Either<SubCategoryDefinition, ActionStatus> subCategoryUniqueForType = elementOperation
+            .getSubCategoryUniqueForType(childNodeType, normalizedName);
         if (subCategoryUniqueForType.isRight()) {
             log.debug("Failed validation of whether similar sub-category exists, normalizedName {} componentType {}", normalizedName, componentType);
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(subCategoryUniqueForType.right().value());
@@ -499,18 +466,16 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         if (subCategoryDefinition != null) {
             subCategoryName = subCategoryDefinition.getName();
         }
-
         subCategory.setName(subCategoryName);
         ///////////////////////////////////////////// Validations end
-
-        Either<SubCategoryDefinition, ActionStatus> createSubCategory = elementOperation.createSubCategory(parentCategoryId, subCategory, childNodeType);
+        Either<SubCategoryDefinition, ActionStatus> createSubCategory = elementOperation
+            .createSubCategory(parentCategoryId, subCategory, childNodeType);
         if (createSubCategory.isRight()) {
             log.debug("Failed to create sub-category, name {}, componentType {}", subCategoryName, componentType);
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(subCategoryUniqueForType.right().value());
             handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         SubCategoryDefinition subCategoryCreated = createSubCategory.left().value();
         log.debug("Created sub-category for component {}, name {}, uniqueId {}", componentType, subCategoryName, subCategoryCreated.getUniqueId());
         ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
@@ -518,25 +483,23 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(subCategoryCreated);
     }
 
-    private void handleComponentException(String userId, AuditingActionEnum auditingAction, String componentType,
-        String parentCategoryName, String origSubCategoryName, ResponseFormat responseFormat) {
+    private void handleComponentException(String userId, AuditingActionEnum auditingAction, String componentType, String parentCategoryName,
+                                          String origSubCategoryName, ResponseFormat responseFormat) {
         User user;
         log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
         user = new User();
         user.setUserId(userId);
-        handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction,
-            componentType);
+        handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
     }
 
-    private void handleComponentException(GroupingDefinition grouping, String userId, AuditingActionEnum auditingAction,
-        String componentType, String parentCategoryName, String parentSubCategoryName, ResponseFormat responseFormat) {
+    private void handleComponentException(GroupingDefinition grouping, String userId, AuditingActionEnum auditingAction, String componentType,
+                                          String parentCategoryName, String parentSubCategoryName, ResponseFormat responseFormat) {
         User user;
         log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
         user = new User();
         user.setUserId(userId);
         String groupingNameForAudit = grouping == null ? null : grouping.getName();
-        handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, groupingNameForAudit,
-            auditingAction, componentType);
+        handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, groupingNameForAudit, auditingAction, componentType);
     }
 
     private void handleComponentException(String componentType, String userId, ResponseFormat responseFormat) {
@@ -547,8 +510,8 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         componentsUtils.auditGetCategoryHierarchy(user, componentType, responseFormat);
     }
 
-    public Either<GroupingDefinition, ResponseFormat> createGrouping(GroupingDefinition grouping, String componentTypeParamName, String grandParentCategoryId, String parentSubCategoryId, String userId) {
-
+    public Either<GroupingDefinition, ResponseFormat> createGrouping(GroupingDefinition grouping, String componentTypeParamName,
+                                                                     String grandParentCategoryId, String parentSubCategoryId, String userId) {
         AuditingActionEnum auditingAction = AuditingActionEnum.ADD_GROUPING;
         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentTypeParamName);
         String componentType = componentTypeEnum == null ? componentTypeParamName : componentTypeEnum.getValue();
@@ -556,41 +519,33 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         // For auditing
         String parentCategoryName = grandParentCategoryId;
         String parentSubCategoryName = parentSubCategoryId;
-
         User user;
-        try{
-            user = validateUserExists(userId, "create Grouping", false);
-        } catch(ByResponseFormatComponentException e){
+        try {
+            user = validateUserExists(userId);
+        } catch (ByResponseFormatComponentException e) {
             ResponseFormat responseFormat = e.getResponseFormat();
-            handleComponentException(grouping, userId, auditingAction, componentType, parentCategoryName,
-                parentSubCategoryName,
-                responseFormat);
+            handleComponentException(grouping, userId, auditingAction, componentType, parentCategoryName, parentSubCategoryName, responseFormat);
             throw e;
-        } catch(ByActionStatusComponentException e){
+        } catch (ByActionStatusComponentException e) {
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
-            handleComponentException(grouping, userId, auditingAction, componentType, parentCategoryName,
-                parentSubCategoryName, responseFormat);
+            handleComponentException(grouping, userId, auditingAction, componentType, parentCategoryName, parentSubCategoryName, responseFormat);
             throw e;
         }
-
         if (grouping == null) {
             log.debug("Grouping json is invalid");
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, null, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         String groupingName = grouping.getName();
         // For auditing of failures we need the original non-normalized name
         String origGroupingName = groupingName;
-
         if (componentTypeEnum == null) {
             log.debug(COMPONENT_TYPE_IS_INVALID, componentTypeParamName);
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Either<Boolean, ResponseFormat> validateComponentType = validateComponentTypeForCategory(componentTypeEnum, categoryType);
         if (validateComponentType.isRight()) {
             log.debug("Validation of component type for grouping failed");
@@ -598,7 +553,6 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Either<Boolean, ResponseFormat> validateUserRole = validateUserRole(user, componentTypeEnum);
         if (validateUserRole.isRight()) {
             log.debug(VALIDATION_OF_USER_ROLE_FAILED_USER_ID, userId);
@@ -606,78 +560,80 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         NodeTypeEnum grandParentNodeType = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.CATEGORY);
         NodeTypeEnum parentNodeType = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.SUBCATEGORY);
         NodeTypeEnum childNodeType = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.GROUPING);
-
         // Validate category
         CategoryDefinition categoryDefinition;
-        Either<CategoryDefinition, ResponseFormat> validateCategoryExists = validateCategoryExists(grandParentNodeType, grandParentCategoryId, componentTypeEnum);
+        Either<CategoryDefinition, ResponseFormat> validateCategoryExists = validateCategoryExists(grandParentNodeType, grandParentCategoryId,
+            componentTypeEnum);
         if (validateCategoryExists.isRight()) {
             log.debug("Validation of parent category exists failed, parent categoryId {}", grandParentCategoryId);
             ResponseFormat responseFormat = validateCategoryExists.right().value();
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         categoryDefinition = validateCategoryExists.left().value();
         parentCategoryName = categoryDefinition.getName();
-
         // Validate subcategory
         SubCategoryDefinition subCategoryDefinition;
-        Either<SubCategoryDefinition, ResponseFormat> validateSubCategoryExists = validateSubCategoryExists(parentNodeType, parentSubCategoryId, componentTypeEnum);
+        Either<SubCategoryDefinition, ResponseFormat> validateSubCategoryExists = validateSubCategoryExists(parentNodeType, parentSubCategoryId,
+            componentTypeEnum);
         if (validateSubCategoryExists.isRight()) {
             log.debug("Validation of parent sub-category exists failed, parent sub-category id {}", parentSubCategoryId);
             ResponseFormat responseFormat = validateSubCategoryExists.right().value();
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         subCategoryDefinition = validateSubCategoryExists.left().value();
         parentSubCategoryName = subCategoryDefinition.getName();
-
         if (!ValidationUtils.validateCategoryDisplayNameFormat(groupingName)) {
             log.debug("Sub-category display name format is invalid, name {}, componentType {}", groupingName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, componentType, categoryType.getValue());
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, componentType, categoryType.getValue());
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         groupingName = ValidationUtils.normalizeCategoryName4Display(groupingName);
-
         if (!ValidationUtils.validateCategoryDisplayNameLength(groupingName)) {
-            log.debug("Grouping display name length is invalid, should be from 4 to 25 chars, name {}, componentType {}", groupingName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, componentType, categoryType.getValue());
+            log.debug("Grouping display name length is invalid, should be from 4 to 25 chars, name {}, componentType {}", groupingName,
+                componentType);
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, componentType, categoryType.getValue());
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(groupingName);
         grouping.setNormalizedName(normalizedName);
-
         // Uniqueness under this category
-        Either<Boolean, ActionStatus> groupingUniqueForSubCategory = elementOperation.isGroupingUniqueForSubCategory(childNodeType, normalizedName, parentSubCategoryId);
+        Either<Boolean, ActionStatus> groupingUniqueForSubCategory = elementOperation
+            .isGroupingUniqueForSubCategory(childNodeType, normalizedName, parentSubCategoryId);
         if (groupingUniqueForSubCategory.isRight()) {
-            log.debug("Failed to check grouping uniqueness, parent name {}, grouping norm name {}, componentType {}", parentSubCategoryName, normalizedName, componentType);
+            log.debug("Failed to check grouping uniqueness, parent name {}, grouping norm name {}, componentType {}", parentSubCategoryName,
+                normalizedName, componentType);
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(groupingUniqueForSubCategory.right().value());
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         Boolean isGroupingUnique = groupingUniqueForSubCategory.left().value();
-        if (!isGroupingUnique) {
-            log.debug("Grouping is not unique for sub-category, parent name {}, grouping norm name {}, componentType {}", parentSubCategoryName, normalizedName, componentType);
-            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY, componentType, groupingName, parentSubCategoryName);
+        if (Boolean.FALSE.equals(isGroupingUnique)) {
+            log.debug("Grouping is not unique for sub-category, parent name {}, grouping norm name {}, componentType {}", parentSubCategoryName,
+                normalizedName, componentType);
+            ResponseFormat responseFormat = componentsUtils
+                .getResponseFormat(ActionStatus.COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY, componentType, groupingName, parentSubCategoryName);
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         // Setting name of grouping to fit the similar grouping name ignoring
+
         // cases.
+
         // For example if Network-->kUKU exists for service sub-category
+
         // Network, and user is trying to create grouping Router-->Kuku for
+
         // service sub-category Router,
+
         // his grouping name will be Router-->kUKU.
         Either<GroupingDefinition, ActionStatus> groupingUniqueForType = elementOperation.getGroupingUniqueForType(childNodeType, normalizedName);
         if (groupingUniqueForType.isRight()) {
@@ -690,10 +646,8 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         if (groupingDefinition != null) {
             groupingName = groupingDefinition.getName();
         }
-
         grouping.setName(groupingName);
         ///////////////////////////////////////////// Validations end
-
         Either<GroupingDefinition, ActionStatus> createGrouping = elementOperation.createGrouping(parentSubCategoryId, grouping, childNodeType);
         if (createGrouping.isRight()) {
             log.debug("Failed to create grouping, name {}, componentType {}", groupingName, componentType);
@@ -701,16 +655,14 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, origGroupingName, auditingAction, componentType);
             return Either.right(responseFormat);
         }
-
         GroupingDefinition groupingCreated = createGrouping.left().value();
         log.debug("Created grouping for component {}, name {}, uniqueId {}", componentType, groupingName, groupingCreated.getUniqueId());
         ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
-        handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, groupingCreated.getName(), auditingAction, componentType);
+        handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, groupingCreated.getName(), auditingAction,
+            componentType);
         return Either.left(groupingCreated);
     }
 
-
-
     public Either<List<CategoryDefinition>, ResponseFormat> getAllCategories(String componentType, String userId) {
         ResponseFormat responseFormat;
         User user = new User();
@@ -721,12 +673,12 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             return Either.right(responseFormat);
         }
         try {
-            user = validateUserExists(userId, "get All Categories", false);
-        } catch (ByActionStatusComponentException e){
+            user = validateUserExists(userId);
+        } catch (ByActionStatusComponentException e) {
             responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
             handleComponentException(componentType, userId, responseFormat);
             throw e;
-        } catch (ByResponseFormatComponentException e){
+        } catch (ByResponseFormatComponentException e) {
             responseFormat = e.getResponseFormat();
             handleComponentException(componentType, userId, responseFormat);
             throw e;
@@ -738,7 +690,6 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             componentsUtils.auditGetCategoryHierarchy(user, componentType, responseFormat);
             return Either.right(responseFormat);
         }
-
         NodeTypeEnum nodeTypeEnum = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.CATEGORY);
         Either<List<CategoryDefinition>, ActionStatus> getAllCategoriesByType = elementOperation.getAllCategories(nodeTypeEnum, false);
         if (getAllCategoriesByType.isRight()) {
@@ -752,57 +703,40 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(categories);
     }
 
-
-
     public Either<UiCategories, ResponseFormat> getAllCategories(String userId) {
         ResponseFormat responseFormat;
         UiCategories categories = new UiCategories();
-
-        User user = validateUserExists(userId, "get all categories", false);
-
+        User user = validateUserExists(userId);
         // GET resource categories
-        Either<List<CategoryDefinition>, ActionStatus> getResourceCategoriesByType = elementOperation.getAllCategories(NodeTypeEnum.ResourceNewCategory, false);
+        Either<List<CategoryDefinition>, ActionStatus> getResourceCategoriesByType = elementOperation
+            .getAllCategories(NodeTypeEnum.ResourceNewCategory, false);
         if (getResourceCategoriesByType.isRight()) {
             responseFormat = componentsUtils.getResponseFormat(getResourceCategoriesByType.right().value());
             componentsUtils.auditGetCategoryHierarchy(user, ComponentTypeEnum.RESOURCE.getValue(), responseFormat);
             return Either.right(responseFormat);
         }
         categories.setResourceCategories(getResourceCategoriesByType.left().value());
-
         // GET service categories
-        Either<List<CategoryDefinition>, ActionStatus> getServiceCategoriesByType = elementOperation.getAllCategories(NodeTypeEnum.ServiceNewCategory, false);
+        Either<List<CategoryDefinition>, ActionStatus> getServiceCategoriesByType = elementOperation
+            .getAllCategories(NodeTypeEnum.ServiceNewCategory, false);
         if (getServiceCategoriesByType.isRight()) {
             responseFormat = componentsUtils.getResponseFormat(getServiceCategoriesByType.right().value());
             componentsUtils.auditGetCategoryHierarchy(user, ComponentTypeEnum.SERVICE.getValue(), responseFormat);
             return Either.right(responseFormat);
         }
         categories.setServiceCategories(getServiceCategoriesByType.left().value());
-
-        // GET product categories
-        Either<List<CategoryDefinition>, ActionStatus> getProductCategoriesByType = elementOperation.getAllCategories(NodeTypeEnum.ProductCategory, false);
-        if (getProductCategoriesByType.isRight()) {
-            responseFormat = componentsUtils.getResponseFormat(getProductCategoriesByType.right().value());
-            componentsUtils.auditGetCategoryHierarchy(user, ComponentTypeEnum.PRODUCT.getValue(), responseFormat);
-            return Either.right(responseFormat);
-        }
-
-        categories.setProductCategories(getProductCategoriesByType.left().value());
+        categories.setProductCategories(new ArrayList<>());
         return Either.left(categories);
-
     }
 
     public Either<CategoryDefinition, ResponseFormat> deleteCategory(String categoryId, String componentTypeParamName, String userId) {
-
-        validateUserExists(userId, "delete Category", false);
-
+        validateUserExists(userId);
         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentTypeParamName);
         if (componentTypeEnum == null) {
             log.debug("Cannot create category for component type {}", componentTypeParamName);
             return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
         }
-
         NodeTypeEnum nodeTypeEnum = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.CATEGORY);
-
         Either<CategoryDefinition, ActionStatus> deleteCategoryByType = elementOperation.deleteCategory(nodeTypeEnum, categoryId);
         if (deleteCategoryByType.isRight()) {
             // auditing, logging here...
@@ -814,17 +748,13 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
     }
 
     public Either<SubCategoryDefinition, ResponseFormat> deleteSubCategory(String parentSubCategoryId, String componentTypeParamName, String userId) {
-
-        validateUserExists(userId, "delete Sub Category", false);
-
+        validateUserExists(userId);
         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentTypeParamName);
         if (componentTypeEnum == null) {
             log.debug("Cannot delete sub-category for component type {}", componentTypeParamName);
             return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
         }
-
         NodeTypeEnum nodeTypeEnum = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.SUBCATEGORY);
-
         Either<SubCategoryDefinition, ActionStatus> deleteSubCategoryByType = elementOperation.deleteSubCategory(nodeTypeEnum, parentSubCategoryId);
         if (deleteSubCategoryByType.isRight()) {
             // auditing, logging here...
@@ -836,17 +766,13 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
     }
 
     public Either<GroupingDefinition, ResponseFormat> deleteGrouping(String groupingId, String componentTypeParamName, String userId) {
-
-        validateUserExists(userId, "delete Grouping", false);
-
+        validateUserExists(userId);
         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentTypeParamName);
         if (componentTypeEnum == null) {
             log.debug("Cannot delete grouping for component type {}", componentTypeParamName);
             return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
         }
-
         NodeTypeEnum nodeTypeEnum = NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(componentTypeEnum, CategoryTypeEnum.GROUPING);
-
         Either<GroupingDefinition, ActionStatus> deleteGroupingByType = elementOperation.deleteGrouping(nodeTypeEnum, groupingId);
         if (deleteGroupingByType.isRight()) {
             // auditing, logging here...
@@ -857,53 +783,33 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(deletedGrouping);
     }
 
-    private Either<User, ResponseFormat> validateUser(String userId) {
-
-        // validate user exists
-        if (userId == null) {
-            log.debug("UserId is null");
-            return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_INFORMATION));
-        }
-
-        Either<User, ActionStatus> userResult = userAdminManager.getUser(userId, false);
-        if (userResult.isRight()) {
-            ResponseFormat responseFormat;
-            if (userResult.right().value().equals(ActionStatus.USER_NOT_FOUND)) {
-                log.debug("Not authorized user, userId = {}", userId);
-                responseFormat = componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION);
-            } else {
-                log.debug("Failed to authorize user, userId = {}", userId);
-                responseFormat = componentsUtils.getResponseFormat(userResult.right().value());
-            }
-
-            return Either.right(responseFormat);
-        }
-        return Either.left(userResult.left().value());
-        // ========================================-
-    }
-
     private Either<Boolean, ResponseFormat> validateUserRole(User user, ComponentTypeEnum componentTypeEnum) {
         String role = user.getRole();
-        boolean validAdminAction = role.equals(Role.ADMIN.name()) && (componentTypeEnum == ComponentTypeEnum.SERVICE || componentTypeEnum == ComponentTypeEnum.RESOURCE);
+        boolean validAdminAction =
+            role.equals(Role.ADMIN.name()) && (componentTypeEnum == ComponentTypeEnum.SERVICE || componentTypeEnum == ComponentTypeEnum.RESOURCE);
         boolean validProductAction = role.equals(Role.PRODUCT_STRATEGIST.name()) && (componentTypeEnum == ComponentTypeEnum.PRODUCT);
-
         if (!(validAdminAction || validProductAction)) {
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION);
-            log.debug("User not permitted to perform operation on category, userId = {}, role = {}, componentType = {}", user.getUserId(), role, componentTypeEnum);
+            log.debug("User not permitted to perform operation on category, userId = {}, role = {}, componentType = {}", user.getUserId(), role,
+                componentTypeEnum);
             return Either.right(responseFormat);
         }
         return Either.left(true);
     }
 
     private Either<Boolean, ResponseFormat> validateComponentTypeForCategory(ComponentTypeEnum componentType, CategoryTypeEnum categoryType) {
-        boolean validResourceAction = componentType == ComponentTypeEnum.RESOURCE && (categoryType == CategoryTypeEnum.CATEGORY || categoryType == CategoryTypeEnum.SUBCATEGORY);
+        boolean validResourceAction = componentType == ComponentTypeEnum.RESOURCE && (categoryType == CategoryTypeEnum.CATEGORY
+            || categoryType == CategoryTypeEnum.SUBCATEGORY);
         boolean validServiceAction = componentType == ComponentTypeEnum.SERVICE && categoryType == CategoryTypeEnum.CATEGORY;
         boolean validProductAction = componentType == ComponentTypeEnum.PRODUCT; // can
+
         // be
+
         // any
+
         // category
-        // type
 
+        // type
         if (!(validResourceAction || validServiceAction || validProductAction)) {
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
             log.debug("It's not allowed to create category type {} for component type {}", categoryType, componentType);
@@ -912,14 +818,16 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(true);
     }
 
-    private Either<CategoryDefinition, ResponseFormat> validateCategoryExists(NodeTypeEnum nodeType, String categoryId, ComponentTypeEnum componentType) {
+    private Either<CategoryDefinition, ResponseFormat> validateCategoryExists(NodeTypeEnum nodeType, String categoryId,
+                                                                              ComponentTypeEnum componentType) {
         Either<CategoryDefinition, ActionStatus> categoryByTypeAndId = elementOperation.getCategory(nodeType, categoryId);
         if (categoryByTypeAndId.isRight()) {
             log.debug("Failed to fetch parent category, parent categoryId {}", categoryId);
             ActionStatus actionStatus = categoryByTypeAndId.right().value();
             ResponseFormat responseFormat;
             if (actionStatus == ActionStatus.COMPONENT_CATEGORY_NOT_FOUND) {
-                responseFormat = componentsUtils.getResponseFormat(actionStatus, componentType.getValue().toLowerCase(), CategoryTypeEnum.CATEGORY.getValue(), "");
+                responseFormat = componentsUtils
+                    .getResponseFormat(actionStatus, componentType.getValue().toLowerCase(), CategoryTypeEnum.CATEGORY.getValue(), "");
             } else {
                 responseFormat = componentsUtils.getResponseFormat(actionStatus);
             }
@@ -928,14 +836,16 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(categoryByTypeAndId.left().value());
     }
 
-    private Either<SubCategoryDefinition, ResponseFormat> validateSubCategoryExists(NodeTypeEnum nodeType, String subCategoryId, ComponentTypeEnum componentType) {
+    private Either<SubCategoryDefinition, ResponseFormat> validateSubCategoryExists(NodeTypeEnum nodeType, String subCategoryId,
+                                                                                    ComponentTypeEnum componentType) {
         Either<SubCategoryDefinition, ActionStatus> subCategoryByTypeAndId = elementOperation.getSubCategory(nodeType, subCategoryId);
         if (subCategoryByTypeAndId.isRight()) {
             log.debug("Failed to fetch parent category, parent categoryId {}", subCategoryId);
             ActionStatus actionStatus = subCategoryByTypeAndId.right().value();
             ResponseFormat responseFormat;
             if (actionStatus == ActionStatus.COMPONENT_CATEGORY_NOT_FOUND) {
-                responseFormat = componentsUtils.getResponseFormat(actionStatus, componentType.getValue().toLowerCase(), CategoryTypeEnum.SUBCATEGORY.getValue(), "");
+                responseFormat = componentsUtils
+                    .getResponseFormat(actionStatus, componentType.getValue().toLowerCase(), CategoryTypeEnum.SUBCATEGORY.getValue(), "");
             } else {
                 responseFormat = componentsUtils.getResponseFormat(actionStatus);
             }
@@ -944,78 +854,70 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(subCategoryByTypeAndId.left().value());
     }
 
-    private void handleCategoryAuditing(ResponseFormat responseFormat, User user, String category, AuditingActionEnum auditingAction, String componentType) {
+    private void handleCategoryAuditing(ResponseFormat responseFormat, User user, String category, AuditingActionEnum auditingAction,
+                                        String componentType) {
         componentsUtils.auditCategory(responseFormat, user, category, null, null, auditingAction, componentType);
     }
 
-    private void handleCategoryAuditing(ResponseFormat responseFormat, User user, String category, String subCategory, AuditingActionEnum auditingAction, String componentType) {
+    private void handleCategoryAuditing(ResponseFormat responseFormat, User user, String category, String subCategory,
+                                        AuditingActionEnum auditingAction, String componentType) {
         componentsUtils.auditCategory(responseFormat, user, category, subCategory, null, auditingAction, componentType);
     }
 
-    private void handleCategoryAuditing(ResponseFormat responseFormat, User user, String category, String subCategory, String grouping, AuditingActionEnum auditingAction, String componentType) {
+    private void handleCategoryAuditing(ResponseFormat responseFormat, User user, String category, String subCategory, String grouping,
+                                        AuditingActionEnum auditingAction, String componentType) {
         componentsUtils.auditCategory(responseFormat, user, category, subCategory, grouping, auditingAction, componentType);
     }
 
     /*
      * New categories flow - end
      */
-
     public Either<List<Tag>, ActionStatus> getAllTags(String userId) {
-        Either<User, ActionStatus> resp = validateUserExistsActionStatus(userId, "get All Tags");
-        if (resp.isRight()) {
-            return Either.right(resp.right().value());
+        ActionStatus status = validateUserExistsActionStatus(userId);
+        if (ActionStatus.OK != status) {
+            return Either.right(status);
         }
         return elementOperation.getAllTags();
     }
 
     public Either<List<PropertyScope>, ActionStatus> getAllPropertyScopes(String userId) {
-        Either<User, ActionStatus> resp = validateUserExistsActionStatus(userId, "get All Property Scopes");
-        if (resp.isRight()) {
-            return Either.right(resp.right().value());
+        ActionStatus status = validateUserExistsActionStatus(userId);
+        if (ActionStatus.OK != status) {
+            return Either.right(status);
         }
         return elementOperation.getAllPropertyScopes();
     }
 
-    public Either<List<ArtifactType>, ActionStatus> getAllArtifactTypes(String userId) {
-        Either<User, ActionStatus> resp = validateUserExistsActionStatus(userId, "get All Artifact Types");
-        if (resp.isRight()) {
-            return Either.right(resp.right().value());
+    public Either<List<ArtifactType>, ActionStatus> getAllArtifactTypes(final String userId) {
+        ActionStatus status = validateUserExistsActionStatus(userId);
+        if (ActionStatus.OK != status) {
+            return Either.right(status);
         }
-        return elementOperation.getAllArtifactTypes();
+        return Either.left(elementOperation.getAllArtifactTypes());
     }
 
-    public Either<Map<String, Object>, ActionStatus> getAllDeploymentArtifactTypes() {
-        return elementOperation.getAllDeploymentArtifactTypes();
-    }
-
-    public Either<Integer, ActionStatus> getDefaultHeatTimeout() {
+    public Either<Configuration.HeatDeploymentArtifactTimeout, ActionStatus> getDefaultHeatTimeout() {
         return elementOperation.getDefaultHeatTimeout();
     }
 
-    public Either<Map<String, List<CatalogComponent>>, ResponseFormat> getCatalogComponents(String userId, List<OriginTypeEnum> excludeTypes) {
+    public Either<Map<String, List<CatalogComponent>>, ResponseFormat> getCatalogComponents(List<OriginTypeEnum> excludeTypes) {
         try {
-            validateUserExists(userId, "get Catalog Components", true);
             return toscaOperationFacade.getCatalogOrArchiveComponents(true, excludeTypes)
-                    .bimap(this::groupByComponentType,
-                            err -> componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(err)));
+                .bimap(this::groupByComponentType, err -> componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(err)));
         } finally {
             janusGraphDao.commit();
         }
     }
 
     private Map<String, List<CatalogComponent>> groupByComponentType(List<CatalogComponent> components) {
-        Map<String, List<CatalogComponent>> map = components.stream().collect(Collectors.groupingBy(cmpt -> cmptTypeToString(cmpt.getComponentType())));
-
+        Map<String, List<CatalogComponent>> map = components.stream()
+            .collect(Collectors.groupingBy(cmpt -> cmptTypeToString(cmpt.getComponentType())));
         // fixed response for UI!!! UI need to receive always map!
         if (map == null) {
             map = new HashMap<>();
         }
-        if (map.get(RESOURCES) == null) {
-            map.put(RESOURCES, new ArrayList());
-        }
-        if (map.get(SERVICES) == null) {
-            map.put(SERVICES, new ArrayList());
-        }
+        map.computeIfAbsent(RESOURCES, k -> new ArrayList());
+        map.computeIfAbsent(SERVICES, k -> new ArrayList());
         return map;
     }
 
@@ -1030,17 +932,17 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         }
     }
 
-    public Either<List<? extends Component>, ResponseFormat> getFilteredCatalogComponents(String assetType, Map<FilterKeyEnum, String> filters, String query) {
+    public Either<List<? extends Component>, ResponseFormat> getFilteredCatalogComponents(String assetType, Map<FilterKeyEnum, String> filters,
+                                                                                          String query) {
         ComponentTypeEnum assetTypeEnum = AssetTypeEnum.convertToComponentTypeEnum(assetType);
-
         if (query != null) {
             Optional<NameValuePair> invalidFilter = findInvalidFilter(query, assetTypeEnum);
             if (invalidFilter.isPresent()) {
                 log.debug("getFilteredAssetList: invalid filter key");
-                return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_FILTER_KEY, invalidFilter.get().getName(), FilterKeyEnum.getValidFiltersByAssetType(assetTypeEnum).toString()));
+                return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_FILTER_KEY, invalidFilter.get().getName(),
+                    FilterKeyEnum.getValidFiltersByAssetType(assetTypeEnum).toString()));
             }
         }
-
         if (filters == null || filters.isEmpty()) {
             Either<List<Component>, StorageOperationStatus> componentsList = toscaOperationFacade.getCatalogComponents(assetTypeEnum, null, false);
             if (componentsList.isRight()) {
@@ -1048,38 +950,35 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             }
             return Either.left(componentsList.left().value());
         }
-
         Either<List<Component>, StorageOperationStatus> result = getFilteredComponents(filters, assetTypeEnum, false);
-
         // category hierarchy mismatch or category/subCategory/distributionStatus not found
         if (result.isRight()) {
             List<String> params = getErrorResponseParams(filters, assetTypeEnum);
-            return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(result.right().value()), params.get(0), params.get(1), params.get(2)));
+            return Either.right(componentsUtils
+                .getResponseFormat(componentsUtils.convertFromStorageResponse(result.right().value()), params.get(0), params.get(1), params.get(2)));
         }
         if (result.left().value().isEmpty()) {// no assets found for requested
+
             // criteria
             return Either.right(componentsUtils.getResponseFormat(ActionStatus.NO_ASSETS_FOUND, assetType, query));
         }
         return Either.left(result.left().value());
     }
 
-    private Either<List<Component>, StorageOperationStatus> getFilteredComponents(Map<FilterKeyEnum, String> filters, ComponentTypeEnum assetType, boolean inTransaction) {
+    private Either<List<Component>, StorageOperationStatus> getFilteredComponents(Map<FilterKeyEnum, String> filters, ComponentTypeEnum assetType,
+                                                                                  boolean inTransaction) {
         Either<List<Component>, StorageOperationStatus> assetResult = Either.left(new LinkedList<>());
         if (assetType == ComponentTypeEnum.RESOURCE) {
-
-            assetResult = getFilteredResouces(filters, inTransaction);
-
+            assetResult = getFilteredResources(filters, inTransaction);
         } else if (assetType == ComponentTypeEnum.SERVICE) {
-
             assetResult = getFilteredServices(filters, inTransaction);
         }
         return assetResult;
     }
 
-    private <T> Either<List<T>, StorageOperationStatus> getFilteredServices(Map<FilterKeyEnum, String> filters, boolean inTransaction) {
-
+    private <T extends Component> Either<List<T>, StorageOperationStatus> getFilteredServices(Map<FilterKeyEnum, String> filters,
+                                                                                              boolean inTransaction) {
         Either<List<T>, StorageOperationStatus> components = null;
-
         String categoryName = filters.get(FilterKeyEnum.CATEGORY);
         String distributionStatus = filters.get(FilterKeyEnum.DISTRIBUTION_STATUS);
         DistributionStatusEnum distEnum = DistributionStatusEnum.findState(distributionStatus);
@@ -1087,43 +986,35 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             filters.remove(FilterKeyEnum.CATEGORY);
             return Either.right(StorageOperationStatus.CATEGORY_NOT_FOUND);
         }
-
         if (categoryName != null) { // primary filter
-            components = fetchByCategoryOrSubCategoryName(categoryName, NodeTypeEnum.ServiceNewCategory, NodeTypeEnum.Service, inTransaction, ServiceMetadataData.class, null);
+            components = fetchByCategoryOrSubCategoryName(categoryName, NodeTypeEnum.ServiceNewCategory, NodeTypeEnum.Service, inTransaction, null);
             if (components.isLeft() && distEnum != null) {// secondary filter
-                Predicate<T> statusFilter = p -> ((Service) p).getDistributionStatus().equals(distEnum);
+                Predicate<T> statusFilter = p -> ((Service) p).getDistributionStatus() == distEnum;
                 return Either.left(components.left().value().stream().filter(statusFilter).collect(Collectors.toList()));
             }
             filters.remove(FilterKeyEnum.DISTRIBUTION_STATUS);
             return components;
         }
-
         Set<DistributionStatusEnum> distStatusSet = new HashSet<>();
         distStatusSet.add(distEnum);
         Either<List<Service>, StorageOperationStatus> servicesWithDistStatus = toscaOperationFacade.getServicesWithDistStatus(distStatusSet, null);
         if (servicesWithDistStatus.isRight()) { // not found == empty list
             return Either.left(new ArrayList<>());
         }
-
         return Either.left((List<T>) servicesWithDistStatus.left().value());
     }
 
     public Either<List<? extends Component>, ResponseFormat> getCatalogComponentsByUuidAndAssetType(String assetType, String uuid) {
-
         if (assetType == null || uuid == null) {
             log.debug("getCatalogComponentsByUuidAndAssetType: One of the function parameteres is null");
             return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
         }
-
         ComponentTypeEnum assetTypeEnum = AssetTypeEnum.convertToComponentTypeEnum(assetType);
-
         if (assetTypeEnum == null) {
             log.debug("getCatalogComponentsByUuidAndAssetType: Corresponding ComponentTypeEnum not found");
             return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
         }
-
         Map<GraphPropertyEnum, Object> additionalPropertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
-
         switch (assetTypeEnum) {
             case RESOURCE:
                 additionalPropertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
@@ -1135,14 +1026,13 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
                 log.debug("getCatalogComponentsByUuidAndAssetType: Corresponding ComponentTypeEnum not allowed for this API");
                 return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
         }
-
-        Either<List<Component>, StorageOperationStatus> componentsListByUuid = toscaOperationFacade.getComponentListByUuid(uuid, additionalPropertiesToMatch);
+        Either<List<Component>, StorageOperationStatus> componentsListByUuid = toscaOperationFacade
+            .getComponentListByUuid(uuid, additionalPropertiesToMatch);
         if (componentsListByUuid.isRight()) {
             log.debug("getCatalogComponentsByUuidAndAssetType: " + assetTypeEnum.getValue() + " fetching failed");
             ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(componentsListByUuid.right().value(), assetTypeEnum);
             return Either.right(componentsUtils.getResponseFormat(actionStatus, uuid));
         }
-
         log.debug("getCatalogComponentsByUuidAndAssetType: " + assetTypeEnum.getValue() + assetTypeEnum.getValue() + "fetching successful");
         return Either.left(componentsListByUuid.left().value());
     }
@@ -1189,14 +1079,12 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return params;
     }
 
-    public Either<List<Component>, StorageOperationStatus> getFilteredResouces(Map<FilterKeyEnum, String> filters, boolean inTransaction) {
-
+    public Either<List<Component>, StorageOperationStatus> getFilteredResources(Map<FilterKeyEnum, String> filters, boolean inTransaction) {
         String subCategoryName = filters.get(FilterKeyEnum.SUB_CATEGORY);
         String categoryName = filters.get(FilterKeyEnum.CATEGORY);
         ResourceTypeEnum resourceType = ResourceTypeEnum.getType(filters.get(FilterKeyEnum.RESOURCE_TYPE));
         Either<List<ImmutablePair<SubCategoryData, GraphEdge>>, StorageOperationStatus> subcategories = null;
         Optional<ImmutablePair<SubCategoryData, GraphEdge>> subCategoryData;
-
         if (categoryName != null) {
             subcategories = getAllSubCategories(categoryName);
             if (subcategories.isRight()) {
@@ -1210,11 +1098,11 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
                 if (!subCategoryData.isPresent()) {
                     return Either.right(StorageOperationStatus.MATCH_NOT_FOUND);
                 }
-                return fetchByCategoryOrSubCategoryUid((String) subCategoryData.get().getLeft().getUniqueId(), NodeTypeEnum.ResourceSubcategory, NodeTypeEnum.Resource, inTransaction,
-                        ResourceMetadataData.class, resourceType);
+                return fetchByCategoryOrSubCategoryUid(subCategoryData.get().getLeft().getUniqueId(), NodeTypeEnum.Resource, inTransaction,
+                    resourceType);
             }
-
-            return fetchByCategoryOrSubCategoryName(subCategoryName, NodeTypeEnum.ResourceSubcategory, NodeTypeEnum.Resource, inTransaction, ResourceMetadataData.class, resourceType);
+            return fetchByCategoryOrSubCategoryName(subCategoryName, NodeTypeEnum.ResourceSubcategory, NodeTypeEnum.Resource, inTransaction,
+                resourceType);
         }
         if (subcategories != null) {
             return fetchByMainCategory(subcategories.left().value(), inTransaction, resourceType);
@@ -1223,14 +1111,14 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
     }
 
     private Either<List<ImmutablePair<SubCategoryData, GraphEdge>>, StorageOperationStatus> getAllSubCategories(String categoryName) {
-        Either<CategoryData, StorageOperationStatus> categoryResult = elementOperation.getNewCategoryData(categoryName, NodeTypeEnum.ResourceNewCategory, CategoryData.class);
+        Either<CategoryData, StorageOperationStatus> categoryResult = elementOperation
+            .getNewCategoryData(categoryName, NodeTypeEnum.ResourceNewCategory, CategoryData.class);
         if (categoryResult.isRight()) {
             return Either.right(categoryResult.right().value());
         }
         CategoryData categoryData = categoryResult.left().value();
-
         Either<List<ImmutablePair<SubCategoryData, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = janusGraphGenericDao
-            .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceNewCategory), (String) categoryData.getUniqueId(),
+            .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceNewCategory), categoryData.getUniqueId(),
                 GraphEdgeLabels.SUB_CATEGORY, NodeTypeEnum.ResourceSubcategory, SubCategoryData.class);
         if (childrenNodes.isRight()) {
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(childrenNodes.right().value()));
@@ -1238,15 +1126,19 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return Either.left(childrenNodes.left().value());
     }
 
-    private Optional<ImmutablePair<SubCategoryData, GraphEdge>> validateCategoryHierarcy(List<ImmutablePair<SubCategoryData, GraphEdge>> childNodes, String subCategoryName) {
-        Predicate<ImmutablePair<SubCategoryData, GraphEdge>> matchName = p -> p.getLeft().getSubCategoryDataDefinition().getName().equals(subCategoryName);
+    private Optional<ImmutablePair<SubCategoryData, GraphEdge>> validateCategoryHierarcy(List<ImmutablePair<SubCategoryData, GraphEdge>> childNodes,
+                                                                                         String subCategoryName) {
+        Predicate<ImmutablePair<SubCategoryData, GraphEdge>> matchName = p -> p.getLeft().getSubCategoryDataDefinition().getName()
+            .equals(subCategoryName);
         return childNodes.stream().filter(matchName).findAny();
     }
 
-    protected <T, S extends ComponentMetadataData> Either<List<T>, StorageOperationStatus> fetchByCategoryOrSubCategoryUid(String categoryUid, NodeTypeEnum categoryType, NodeTypeEnum neededType, boolean inTransaction,
-                                                                                                                           Class<S> clazz, ResourceTypeEnum resourceType) {
+    protected <T extends Component> Either<List<T>, StorageOperationStatus> fetchByCategoryOrSubCategoryUid(String categoryUid,
+                                                                                                            NodeTypeEnum categoryType,
+                                                                                                            boolean inTransaction,
+                                                                                                            ResourceTypeEnum resourceType) {
         try {
-            return collectComponents(neededType, categoryUid, categoryType, clazz, resourceType);
+            return collectComponents(categoryType, categoryUid, resourceType);
         } finally {
             if (!inTransaction) {
                 janusGraphDao.commit();
@@ -1254,26 +1146,31 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         }
     }
 
-    protected <T, S extends ComponentMetadataData> Either<List<T>, StorageOperationStatus> fetchByCategoryOrSubCategoryName(String categoryName, NodeTypeEnum categoryType, NodeTypeEnum neededType, boolean inTransaction,
-                                                                                                                            Class<S> clazz, ResourceTypeEnum resourceType) {
+    protected <T extends Component> Either<List<T>, StorageOperationStatus> fetchByCategoryOrSubCategoryName(String categoryName,
+                                                                                                             NodeTypeEnum categoryType,
+                                                                                                             NodeTypeEnum neededType,
+                                                                                                             boolean inTransaction,
+                                                                                                             ResourceTypeEnum resourceType) {
         List<T> components = new ArrayList<>();
         try {
             Class categoryClazz = categoryType == NodeTypeEnum.ServiceNewCategory ? CategoryData.class : SubCategoryData.class;
             Map<String, Object> props = new HashMap<>();
             props.put(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty(), ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
-            Either<List<GraphNode>, JanusGraphOperationStatus> getCategory = janusGraphGenericDao
-                .getByCriteria(categoryType, props, categoryClazz);
+            Either<List<GraphNode>, JanusGraphOperationStatus> getCategory = janusGraphGenericDao.getByCriteria(categoryType, props, categoryClazz);
             if (getCategory.isRight()) {
                 return Either.right(StorageOperationStatus.CATEGORY_NOT_FOUND);
             }
             for (GraphNode category : getCategory.left().value()) {
-                Either<List<T>, StorageOperationStatus> result = collectComponents(neededType, (String) category.getUniqueId(), categoryType, clazz, resourceType);
-                if (result.isRight()) {
+                Either<List<T>, StorageOperationStatus> result = collectComponents(neededType, category.getUniqueId(), resourceType);
+                if (result.isRight() && result.right().value() != StorageOperationStatus.NOT_FOUND) {
                     return result;
+                } else if (result.isLeft()) {
+                    components.addAll(result.left().value());
                 }
-                components.addAll(result.left().value());
             }
-
+            if (components.isEmpty()) {
+                return Either.right(StorageOperationStatus.NOT_FOUND);
+            }
             return Either.left(components);
         } finally {
             if (!inTransaction) {
@@ -1282,33 +1179,45 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         }
     }
 
-
-    private <T, S extends ComponentMetadataData> Either<List<T>, StorageOperationStatus> collectComponents(NodeTypeEnum neededType, String categoryUid, NodeTypeEnum categoryType, Class<S> clazz, ResourceTypeEnum resourceType) {
+    private <T extends Component> Either<List<T>, StorageOperationStatus> collectComponents(NodeTypeEnum neededType, String categoryUid,
+                                                                                            ResourceTypeEnum resourceType) {
         List<T> components = new ArrayList<>();
-        Either<List<ImmutablePair<S, GraphEdge>>, JanusGraphOperationStatus> parentNodes = janusGraphGenericDao
-            .getParentNodes(UniqueIdBuilder.getKeyByNodeType(categoryType), categoryUid, GraphEdgeLabels.CATEGORY, neededType, clazz);
-        if (parentNodes.isLeft()) {
-            for (ImmutablePair<S, GraphEdge> component : parentNodes.left().value()) {
-                ComponentMetadataDataDefinition componentData = component.getLeft().getMetadataDataDefinition();
-                Boolean isHighest = componentData.isHighestVersion();
-                boolean isMatchingResourceType = isMatchingByResourceType(neededType, resourceType, componentData);
-                boolean isDeleted = isTrue(componentData.isDeleted());
-                boolean isArchived = isTrue(componentData.isArchived());
-
-                if (isHighest && isMatchingResourceType && !isDeleted && !isArchived) {
-                    Either<T, StorageOperationStatus> result = (Either<T, StorageOperationStatus>) toscaOperationFacade.getToscaElement(componentData.getUniqueId(), JsonParseFlagEnum.ParseMetadata);
-                    if (result.isRight()) {
-                        return Either.right(result.right().value());
-                    }
-                    components.add(result.left().value());
+        Either<GraphVertex, JanusGraphOperationStatus> categoryVertexById = janusGraphDao.getVertexById(categoryUid, JsonParseFlagEnum.NoParse);
+        if (categoryVertexById.isRight()) {
+            JanusGraphOperationStatus status = categoryVertexById.right().value();
+            log.debug("#collectComponents Failed to get category vertex with uid {}, status is {}.", categoryUid, status);
+            return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
+        }
+        GraphVertex categoryVertex = categoryVertexById.left().value();
+        Either<List<GraphVertex>, JanusGraphOperationStatus> componentsVertices = janusGraphDao
+            .getParentVertices(categoryVertex, EdgeLabelEnum.CATEGORY, JsonParseFlagEnum.ParseMetadata);
+        if (componentsVertices.isRight()) {
+            JanusGraphOperationStatus status = componentsVertices.right().value();
+            log.debug("#collectComponents Failed to get components vertices of category {}, status is {}.", categoryVertex, status);
+            return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
+        }
+        List<ComponentMetadataDataDefinition> componentsMetadataDataDefinition = componentsVertices.left().value().stream().filter(Objects::nonNull)
+            .filter(componentsVertex -> Objects.nonNull(componentsVertex.getType())).map(ModelConverter::convertToComponentMetadataDataDefinition)
+            .collect(Collectors.toList());
+        for (ComponentMetadataDataDefinition component : componentsMetadataDataDefinition) {
+            boolean isHighest = isTrue(component.isHighestVersion());
+            boolean isMatchingResourceType = isMatchingByResourceType(neededType, resourceType, component);
+            boolean isDeleted = isTrue(component.isDeleted());
+            boolean isArchived = isTrue(component.isArchived());
+            if (isHighest && isMatchingResourceType && !isDeleted && !isArchived) {
+                Either<T, StorageOperationStatus> result = toscaOperationFacade
+                    .getToscaElement(component.getUniqueId(), JsonParseFlagEnum.ParseMetadata);
+                if (result.isRight()) {
+                    return Either.right(result.right().value());
                 }
+                components.add(result.left().value());
             }
         }
         return Either.left(components);
     }
 
-    private boolean isMatchingByResourceType(NodeTypeEnum componentType, ResourceTypeEnum resourceType, ComponentMetadataDataDefinition componentData) {
-
+    private boolean isMatchingByResourceType(NodeTypeEnum componentType, ResourceTypeEnum resourceType,
+                                             ComponentMetadataDataDefinition componentData) {
         boolean isMatching;
         if (componentType == NodeTypeEnum.Resource) {
             if (resourceType == null) {
@@ -1322,12 +1231,12 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         return isMatching;
     }
 
-    private <T> Either<List<T>, StorageOperationStatus> fetchByMainCategory(List<ImmutablePair<SubCategoryData, GraphEdge>> subcategories, boolean inTransaction, ResourceTypeEnum resourceType) {
+    private <T extends Component> Either<List<T>, StorageOperationStatus> fetchByMainCategory(
+        List<ImmutablePair<SubCategoryData, GraphEdge>> subcategories, boolean inTransaction, ResourceTypeEnum resourceType) {
         List<T> components = new ArrayList<>();
-
         for (ImmutablePair<SubCategoryData, GraphEdge> subCategory : subcategories) {
-            Either<List<T>, StorageOperationStatus> fetched = fetchByCategoryOrSubCategoryUid((String) subCategory.getLeft().getUniqueId(), NodeTypeEnum.ResourceSubcategory, NodeTypeEnum.Resource,
-                    inTransaction, ResourceMetadataData.class, resourceType);
+            Either<List<T>, StorageOperationStatus> fetched = fetchByCategoryOrSubCategoryUid(subCategory.getLeft().getUniqueId(),
+                NodeTypeEnum.Resource, inTransaction, resourceType);
             if (fetched.isRight()) {
                 continue;
             }
@@ -1342,8 +1251,10 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         Wrapper<StorageOperationStatus> statusWrapper = new Wrapper<>();
         Either<List<Component>, StorageOperationStatus> result;
         try {
-            ComponentParametersView fetchUsersAndCategoriesFilter = new ComponentParametersView(Arrays.asList(ComponentFieldsEnum.USERS.getValue(), ComponentFieldsEnum.CATEGORIES.getValue()));
-            Either<List<Component>, StorageOperationStatus> getResources = toscaOperationFacade.fetchMetaDataByResourceType(resourceType, fetchUsersAndCategoriesFilter);
+            ComponentParametersView fetchUsersAndCategoriesFilter = new ComponentParametersView(
+                Arrays.asList(ComponentFieldsEnum.USERS.getValue(), ComponentFieldsEnum.CATEGORIES.getValue()));
+            Either<List<Component>, StorageOperationStatus> getResources = toscaOperationFacade
+                .fetchMetaDataByResourceType(resourceType, fetchUsersAndCategoriesFilter);
             if (getResources.isRight()) {
                 status = getResources.right().value();
                 if (status != StorageOperationStatus.NOT_FOUND) {
@@ -1366,4 +1277,40 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
             }
         }
     }
+
+    public CatalogUpdateTimestamp getCatalogUpdateTime() {
+        try {
+            return toscaOperationFacade.getCatalogTimes();
+        } finally {
+            janusGraphDao.commit();
+        }
+    }
+
+    public Either<List<BaseType>, ActionStatus> getBaseTypes(final String categoryName, final String userId, final String modelName) {
+        final ActionStatus status = validateUserExistsActionStatus(userId);
+        if (ActionStatus.OK != status) {
+            return Either.right(status);
+        }
+        return Either.left(elementOperation.getServiceBaseTypes(categoryName, modelName));
+    }
+
+    /**
+     * Checks if a category requires a base type.
+     *
+     * @param categoryName the category name
+     * @return {@code true} if a base type is required, {@code false} otherwise.
+     */
+    public boolean isBaseTypeRequired(final String categoryName) {
+        return elementOperation.isBaseTypeRequired(categoryName);
+    }
+
+    /**
+     * Fetches default baseType from the template.
+     *
+     * @param categoryName the category name
+     * @return defaultBaseType mapped to the corresponding category name.
+     */
+    public String getDefaultBaseType(final String categoryName) {
+        return elementOperation.getDefaultBaseType(categoryName);
+    }
 }