From ee8876059c520d97bf068734b25a02365d7fe1ea Mon Sep 17 00:00:00 2001 From: vasraz Date: Thu, 14 Jul 2022 21:06:58 +0100 Subject: Support Outputs during Import Service Signed-off-by: Vasyl Razinkov Change-Id: I4d58576b70ef738d6fa7545cd268ec030b43f95c Issue-ID: SDC-4051 --- .../attribute/DefaultAttributeDeclarator.java | 9 +- .../csar/YamlTemplateParsingHandler.java | 17 +++- .../sdc/be/components/impl/ImportUtils.java | 70 +++++++++----- .../be/components/impl/InputsBusinessLogic.java | 43 +++++---- .../be/components/impl/OutputsBusinessLogic.java | 102 +++++++++++++++++---- .../impl/ServiceImportBusinessLogic.java | 18 +++- .../components/impl/ServiceImportParseLogic.java | 38 ++++---- .../be/servlets/AbstractValidationsServlet.java | 14 +-- .../openecomp/sdc/be/servlets/ServiceServlet.java | 14 ++- 9 files changed, 216 insertions(+), 109 deletions(-) (limited to 'catalog-be/src/main') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java index 79bfcc6df7..394d6b314b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java @@ -25,7 +25,6 @@ import com.google.gson.Gson; import fj.data.Either; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -182,7 +181,7 @@ public abstract class DefaultAttributeDeclarator mappedToscaTemplate = (Map) objValue; @@ -218,7 +217,7 @@ public abstract class DefaultAttributeDeclarator nodeTypesInfo, String nodeName, Component component, String interfaceTemplateYaml) { log.debug("#parseResourceInfoFromYAML - Going to parse yaml {} ", fileName); - Map mappedToscaTemplate = getMappedToscaTemplate(fileName, resourceYml, nodeTypesInfo, nodeName); - ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo(); - Map mappedTopologyTemplate = (Map) findToscaElement(mappedToscaTemplate, TOPOLOGY_TEMPLATE, + final Map mappedToscaTemplate = getMappedToscaTemplate(fileName, resourceYml, nodeTypesInfo, nodeName); + final ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo(); + final Map mappedTopologyTemplate = (Map) findToscaElement(mappedToscaTemplate, TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL).left().on(err -> failIfNotTopologyTemplate(fileName)); - Map mappedTopologyTemplateInputs = mappedTopologyTemplate.entrySet().stream() + final Map mappedTopologyTemplateInputs = mappedTopologyTemplate.entrySet().stream() .filter(entry -> entry.getKey().equals(INPUTS.getElementName())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + final Map mappedTopologyTemplateOutputs = mappedTopologyTemplate.entrySet().stream() + .filter(entry -> entry.getKey().equals(OUTPUTS.getElementName())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); parsedToscaYamlInfo.setInputs(getInputs(mappedTopologyTemplateInputs)); + parsedToscaYamlInfo.setOutputs(getOutputs(mappedTopologyTemplateOutputs)); parsedToscaYamlInfo.setInstances(getInstances(mappedToscaTemplate, createdNodesToscaResourceNames)); parsedToscaYamlInfo.setGroups(getGroups(mappedToscaTemplate, component.getModel())); parsedToscaYamlInfo.setPolicies(getPolicies(mappedToscaTemplate, component.getModel())); @@ -190,6 +195,10 @@ public class YamlTemplateParsingHandler { return inputs; } + private Map getOutputs(Map toscaJson) { + return ImportUtils.getOutputs(toscaJson).left().on(err -> new HashMap<>()); + } + private Map getProperties(Map toscaJson) { return ImportUtils.getProperties(toscaJson).left().on(err -> new HashMap<>()); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java index 7719187cda..b4f6ee3950 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java @@ -41,7 +41,7 @@ import java.util.Map.Entry; import java.util.function.Consumer; import java.util.function.Function; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.onap.sdc.tosca.datatypes.model.EntrySchema; import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -56,6 +56,7 @@ import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.HeatParameterDefinition; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.OutputDefinition; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.heat.HeatParameterType; @@ -92,8 +93,8 @@ public final class ImportUtils { } @Autowired - public static void setComponentsUtils(ComponentsUtils componentsUtils) { - componentsUtils = componentsUtils; + public static void setComponentsUtils(ComponentsUtils cu) { + componentsUtils = cu; } private static void buildMap(Map output, Map map) { @@ -257,8 +258,8 @@ public final class ImportUtils { * @param toscaTagName * @return */ - public static Either findFirstToscaBooleanElement(Map toscaJson, - TypeUtils.ToscaTagNamesEnum toscaTagName) { + private static Either findFirstToscaBooleanElement(Map toscaJson, + TypeUtils.ToscaTagNamesEnum toscaTagName) { Either returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either findFirstToscaElements = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.BOOLEAN); if (findFirstToscaElements.isLeft()) { @@ -310,7 +311,7 @@ public final class ImportUtils { } catch (ClassCastException | JsonParseException e) { throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT, constraintJson.toString()); } - if (propertyConstraint != null && propertyConstraint instanceof ValidValuesConstraint) { + if (propertyConstraint instanceof ValidValuesConstraint) { try { ((ValidValuesConstraint) propertyConstraint).validateType(propertyType); } catch (ConstraintValueDoNotMatchPropertyTypeException e) { @@ -323,7 +324,7 @@ public final class ImportUtils { return propertyConstraint; } - public static PropertyDefinition createModuleProperty(Map propertyValue) { + static PropertyDefinition createModuleProperty(Map propertyValue) { PropertyDefinition propertyDef = new PropertyDefinition(); setField(propertyValue, TypeUtils.ToscaTagNamesEnum.TYPE, propertyDef::setType); setFieldBoolean(propertyValue, ToscaTagNamesEnum.REQUIRED, req -> propertyDef.setRequired(Boolean.parseBoolean(req))); @@ -340,12 +341,11 @@ public final class ImportUtils { private static void setJsonStringField(Map propertyValue, ToscaTagNamesEnum elementName, String type, Consumer setter) { Either eitherValue = findToscaElement(propertyValue, elementName, ToscaElementTypeEnum.ALL); if (eitherValue.isLeft()) { - String propertyJsonStringValue = getPropertyJsonStringValue(eitherValue.left().value(), type); - setter.accept(propertyJsonStringValue); + setter.accept(getPropertyJsonStringValue(eitherValue.left().value(), type)); } } - public static Annotation createModuleAnnotation(Map annotationMap, AnnotationTypeOperations annotationTypeOperations) { + private static Annotation createModuleAnnotation(Map annotationMap, AnnotationTypeOperations annotationTypeOperations) { String parsedAnnotationType = findFirstToscaStringElement(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE).left().value(); AnnotationTypeDefinition annotationTypeObject = annotationTypeOperations.getLatestType(parsedAnnotationType); if (annotationTypeObject != null) { @@ -387,11 +387,11 @@ public final class ImportUtils { return result; } - public static InputDefinition createModuleInput(final Map inputValue, final AnnotationTypeOperations annotationTypeOperations) { + private static InputDefinition createModuleInput(final Map inputValue, final AnnotationTypeOperations annotationTypeOperations) { return parseAnnotationsAndAddItToInput(createModuleInput(inputValue), inputValue, annotationTypeOperations); } - public static InputDefinition createModuleInput(final Map inputValue) { + private static InputDefinition createModuleInput(final Map inputValue) { final InputDefinition inputDef = new InputDefinition(); setField(inputValue, TypeUtils.ToscaTagNamesEnum.TYPE, inputDef::setType); setFieldBoolean(inputValue, ToscaTagNamesEnum.REQUIRED, req -> inputDef.setRequired(Boolean.parseBoolean(req))); @@ -408,8 +408,17 @@ public final class ImportUtils { return inputDef; } - public static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef, Map inputValue, - AnnotationTypeOperations annotationTypeOperations) { + private static OutputDefinition createModuleOutput(final Map outputValue) { + final OutputDefinition outputDef = new OutputDefinition(); + setField(outputValue, TypeUtils.ToscaTagNamesEnum.TYPE, outputDef::setType); + setField(outputValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, outputDef::setDescription); + setJsonStringField(outputValue, TypeUtils.ToscaTagNamesEnum.VALUE, outputDef.getType(), outputDef::setValue); + setField(outputValue, TypeUtils.ToscaTagNamesEnum.STATUS, outputDef::setStatus); + return outputDef; + } + + private static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef, Map inputValue, + AnnotationTypeOperations annotationTypeOperations) { Function elementGenByName = ImportUtils::createAnnotation; Function, Annotation> func = annotation -> createModuleAnnotation(annotation, annotationTypeOperations); return getElements(inputValue, TypeUtils.ToscaTagNamesEnum.ANNOTATIONS, elementGenByName, func).left() @@ -425,7 +434,7 @@ public final class ImportUtils { return inputDef; } - public static AttributeDefinition createModuleAttribute(Map attributeMap) { + static AttributeDefinition createModuleAttribute(Map attributeMap) { AttributeDefinition attributeDef = new AttributeDefinition(); setField(attributeMap, TypeUtils.ToscaTagNamesEnum.TYPE, attributeDef::setType); setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, attributeDef::setDescription); @@ -486,7 +495,7 @@ public final class ImportUtils { } } - public static void setFieldBoolean(Map toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer setter) { + private static void setFieldBoolean(Map toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer setter) { Either fieldStringValue = findFirstToscaBooleanElement(toscaJson, tagName); if (fieldStringValue.isLeft()) { setter.accept(fieldStringValue.left().value()); @@ -520,13 +529,19 @@ public final class ImportUtils { return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS, elementGenByName, func); } + public static Either, ResultStatusEnum> getOutputs(Map toscaJson) { + final Function elementGenByName = ImportUtils::createOutputs; + final Function, OutputDefinition> func = ImportUtils::createModuleOutput; + return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.OUTPUTS, elementGenByName, func); + } + public static Either, ResultStatusEnum> getInputs(final Map toscaJson) { return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS, ImportUtils::createInputs, ImportUtils::createModuleInput); } - public static Either, ResultStatusEnum> getElements(Map toscaJson, TypeUtils.ToscaTagNamesEnum elementTagName, - Function elementGenByName, - Function, T> func) { + private static Either, ResultStatusEnum> getElements(Map toscaJson, TypeUtils.ToscaTagNamesEnum elementTagName, + Function elementGenByName, + Function, T> func) { Either, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(toscaJson, elementTagName); if (toscaAttributes.isLeft()) { @@ -571,13 +586,19 @@ public final class ImportUtils { return input; } + private static OutputDefinition createOutputs(final String name) { + final OutputDefinition output = new OutputDefinition(); + output.setName(name); + return output; + } + private static Annotation createAnnotation(String name) { Annotation annotation = new Annotation(); annotation.setName(name); return annotation; } - public static Either, ResultStatusEnum> getHeatParameters(Map heatData, String artifactType) { + static Either, ResultStatusEnum> getHeatParameters(Map heatData, String artifactType) { Either, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND); Either, ResultStatusEnum> toscaProperties = findFirstToscaMapElement(heatData, TypeUtils.ToscaTagNamesEnum.PARAMETERS); if (toscaProperties.isLeft()) { @@ -657,13 +678,16 @@ public final class ImportUtils { } public static String getPropertyJsonStringValue(Object value, String type) { - Gson gson = new Gson(); if (type == null) { return null; } ToscaPropertyType validType = ToscaPropertyType.isValidType(type); - if (validType == null || validType == ToscaPropertyType.JSON || validType == ToscaPropertyType.MAP || validType == ToscaPropertyType.LIST) { - return gson.toJson(value); + if (validType == null + || validType == ToscaPropertyType.JSON + || validType == ToscaPropertyType.MAP + || validType == ToscaPropertyType.LIST + || value instanceof Map) { + return (new Gson()).toJson(value); } return value.toString(); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java index 18993e8f65..bca901ee8b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java @@ -127,14 +127,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic { ComponentParametersView filters = new ComponentParametersView(); filters.disableAll(); filters.setIgnoreInputs(false); - Either getComponentEither = toscaOperationFacade + Either getComponentEither = toscaOperationFacade .getToscaElement(componentId, filters); if (getComponentEither.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value()); log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus); return Either.right(componentsUtils.getResponseFormat(actionStatus)); } - org.openecomp.sdc.be.model.Component component = getComponentEither.left().value(); + Component component = getComponentEither.left().value(); List inputs = component.getInputs(); return Either.left(inputs); } @@ -147,14 +147,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic { filters.setIgnoreInputs(false); filters.setIgnoreComponentInstances(false); filters.setIgnoreComponentInstancesInputs(false); - Either getComponentEither = toscaOperationFacade + Either getComponentEither = toscaOperationFacade .getToscaElement(componentId, filters); if (getComponentEither.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value()); log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus); return Either.right(componentsUtils.getResponseFormat(actionStatus)); } - org.openecomp.sdc.be.model.Component component = getComponentEither.left().value(); + Component component = getComponentEither.left().value(); if (!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)) { ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND; log.debug("Failed to found component instance inputs {}, error: {}", componentInstanceId, actionStatus); @@ -182,12 +182,12 @@ public class InputsBusinessLogic extends BaseBusinessLogic { String instanceId, String inputId) { validateUserExists(userId); String parentId = componentId; - org.openecomp.sdc.be.model.Component component; + Component component; ComponentParametersView filters = new ComponentParametersView(); filters.disableAll(); filters.setIgnoreComponentInstances(false); if (!instanceId.equals(inputId)) { - Either getComponentEither = toscaOperationFacade + Either getComponentEither = toscaOperationFacade .getToscaElement(parentId, filters); if (getComponentEither.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value()); @@ -204,7 +204,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { filters.setIgnoreComponentInstancesProperties(false); filters.setIgnoreComponentInstancesInputs(false); filters.setIgnoreProperties(false); - Either getComponentEither = toscaOperationFacade + Either getComponentEither = toscaOperationFacade .getToscaElement(parentId, filters); if (getComponentEither.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value()); @@ -266,7 +266,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { List inputs, String userId, boolean shouldLockComp) { List returnInputs = new ArrayList<>(); Either, ResponseFormat> result = null; - org.openecomp.sdc.be.model.Component component = null; + Component component = null; try { validateUserExists(userId); ComponentParametersView componentParametersView = new ComponentParametersView(); @@ -353,14 +353,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic { public Either, ResponseFormat> getInputsForComponentInput(String userId, String componentId, String inputId) { validateUserExists(userId); - org.openecomp.sdc.be.model.Component component = null; + Component component = null; ComponentParametersView filters = new ComponentParametersView(); filters.disableAll(); filters.setIgnoreComponentInstances(false); filters.setIgnoreInputs(false); filters.setIgnoreComponentInstancesInputs(false); filters.setIgnoreProperties(false); - Either getComponentEither = toscaOperationFacade + Either getComponentEither = toscaOperationFacade .getToscaElement(componentId, filters); if (getComponentEither.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value()); @@ -388,7 +388,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { boolean shouldLockComp, boolean inTransaction) { Either, ResponseFormat> result = null; - org.openecomp.sdc.be.model.Component component = null; + Component component = null; try { validateUserExists(userId); component = getAndValidateComponentForCreate(userId, componentId, componentType, shouldLockComp); @@ -431,7 +431,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { ComponentInstListInput componentListInput, boolean shouldLockComp, boolean inTransaction) { Either, ResponseFormat> result = null; - org.openecomp.sdc.be.model.Component component = null; + Component component = null; log.trace("#createListInput: enter"); try { /* check if user exists */ @@ -513,11 +513,11 @@ public class InputsBusinessLogic extends BaseBusinessLogic { return componentParametersView; } - private org.openecomp.sdc.be.model.Component getAndValidateComponentForCreate( + private Component getAndValidateComponentForCreate( String userId, String componentId, ComponentTypeEnum componentType, boolean shouldLockComp ) { ComponentParametersView componentParametersView = getBaseComponentParametersView(); - org.openecomp.sdc.be.model.Component component = validateComponentExists(componentId, componentType, componentParametersView); + Component component = validateComponentExists(componentId, componentType, componentParametersView); if (shouldLockComp) { // lock the component lockComponent(component, CREATE_INPUT); @@ -566,7 +566,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { } public Either, ResponseFormat> createInputsInGraph(Map inputs, - org.openecomp.sdc.be.model.Component component) { + Component component) { List resourceProperties = component.getInputs(); @@ -604,7 +604,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { private Either, ResponseFormat> createListInputsInGraph(Map inputs, Map privateDataTypes, - org.openecomp.sdc.be.model.Component component) { + Component component) { log.trace("#createListInputsInGraph: enter"); @@ -652,12 +652,12 @@ public class InputsBusinessLogic extends BaseBusinessLogic { componentParametersView.setIgnoreInterfaces(false); componentParametersView.setIgnoreDataType(false); componentParametersView.setIgnoreProperties(false); - Either componentEither = toscaOperationFacade + Either componentEither = toscaOperationFacade .getToscaElement(componentId, componentParametersView); if (componentEither.isRight()) { throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(componentEither.right().value())); } - org.openecomp.sdc.be.model.Component component = componentEither.left().value(); + Component component = componentEither.left().value(); // Validate inputId is child of the component Optional optionalInput = component.getInputs().stream(). // filter by ID @@ -700,10 +700,9 @@ public class InputsBusinessLogic extends BaseBusinessLogic { } private Either deleteListInput(String componentId, String inputId, - org.openecomp.sdc.be.model.Component component, InputDefinition inputForDelete, + Component component, InputDefinition inputForDelete, StorageOperationStatus status) { // the input is created by 'Declare List'. - // need to 1. undeclare properties, 2. delete input, 3. delete private data type StorageOperationStatus storageOperationStatus = propertyDeclarationOrchestrator.unDeclarePropertiesAsListInputs(component, inputForDelete); if (storageOperationStatus != StorageOperationStatus.OK) { @@ -762,14 +761,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic { filters.setIgnoreComponentInstancesInputs(false); filters.setIgnoreComponentInstancesProperties(false); filters.setIgnoreProperties(false); - Either getComponentEither = toscaOperationFacade + Either getComponentEither = toscaOperationFacade .getToscaElement(componentId, filters); if (getComponentEither.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value()); log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus); return Either.right(componentsUtils.getResponseFormat(actionStatus)); } - org.openecomp.sdc.be.model.Component component = getComponentEither.left().value(); + Component component = getComponentEither.left().value(); Optional op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst(); if (!op.isPresent()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value()); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java index 2d6a619cc7..a5f819d9b0 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java @@ -20,10 +20,12 @@ package org.openecomp.sdc.be.components.impl; import fj.data.Either; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; +import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.be.components.attribute.AttributeDeclarationOrchestrator; import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; @@ -32,8 +34,12 @@ import org.openecomp.sdc.be.components.validation.ComponentValidations; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.utils.MapUtil; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstOutputsMap; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceAttribOutput; +import org.openecomp.sdc.be.model.ComponentInstanceAttribute; import org.openecomp.sdc.be.model.ComponentInstanceOutput; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.OutputDefinition; @@ -51,6 +57,7 @@ import org.openecomp.sdc.common.log.enums.StatusCode; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; @org.springframework.stereotype.Component("outputsBusinessLogic") public class OutputsBusinessLogic extends BaseBusinessLogic { @@ -58,8 +65,8 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { private static final String CREATE_OUTPUT = "CreateOutput"; private static final Logger log = Logger.getLogger(OutputsBusinessLogic.class); private static final String FAILED_TO_FOUND_COMPONENT_ERROR = "Failed to found component {}, error: {}"; - private static final String GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP = "Going to execute rollback on create group."; - private static final String GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP = "Going to execute commit on create group."; + private static final String GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_OUTPUTS = "Going to execute rollback on create outputs."; + private static final String GOING_TO_EXECUTE_COMMIT_ON_CREATE_OUTPUTS = "Going to execute commit on create outputs."; private static final LoggerSupportability loggerSupportability = LoggerSupportability.getLogger(OutputsBusinessLogic.class); private static final String FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_COMPONENT_INSTANCE_ID = "Failed to found component instance outputs componentInstanceId: {}"; private static final String FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_ERROR = "Failed to found component instance outputs {}, error: {}"; @@ -94,7 +101,7 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { if (!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)) { final ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND; log.debug(FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_ERROR, componentInstanceId, actionStatus); - loggerSupportability.log(LoggerSupportabilityActions.CREATE_INPUTS, component.getComponentMetadataForSupportLog(), StatusCode.ERROR, + loggerSupportability.log(LoggerSupportabilityActions.CREATE_OUTPUTS, component.getComponentMetadataForSupportLog(), StatusCode.ERROR, FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_COMPONENT_INSTANCE_ID, componentInstanceId); return Either.right(componentsUtils.getResponseFormat(actionStatus)); } @@ -110,11 +117,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { return createMultipleOutputs(userId, componentId, componentTypeEnum, componentInstOutputsMap, true, false); } - public Either, ResponseFormat> createMultipleOutputs(final String userId, final String componentId, - final ComponentTypeEnum componentType, - final ComponentInstOutputsMap componentInstOutputsMapUi, - final boolean shouldLockComp, final boolean inTransaction) { - Either, ResponseFormat> result = null; + private Either, ResponseFormat> createMultipleOutputs(final String userId, final String componentId, + final ComponentTypeEnum componentType, + final ComponentInstOutputsMap componentInstOutputsMapUi, + final boolean shouldLockComp, final boolean inTransaction) { + Either, ResponseFormat> result = Either.right(new ResponseFormat(HttpStatus.BAD_REQUEST.value())); org.openecomp.sdc.be.model.Component component = null; try { validateUserExists(userId); @@ -129,11 +136,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { return result; } finally { if (!inTransaction) { - if (result == null || result.isRight()) { - log.debug(GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP); + if (result.isRight()) { + log.debug(GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_OUTPUTS); janusGraphDao.rollback(); } else { - log.debug(GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP); + log.debug(GOING_TO_EXECUTE_COMMIT_ON_CREATE_OUTPUTS); janusGraphDao.commit(); } } @@ -144,11 +151,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { } } - private org.openecomp.sdc.be.model.Component getAndValidateComponentForCreate(final String userId, final String componentId, - final ComponentTypeEnum componentType, - final boolean shouldLockComp) { + private Component getAndValidateComponentForCreate(final String userId, final String componentId, + final ComponentTypeEnum componentType, + final boolean shouldLockComp) { final ComponentParametersView componentParametersView = getBaseComponentParametersView(); - final org.openecomp.sdc.be.model.Component component = validateComponentExists(componentId, componentType, componentParametersView); + final Component component = validateComponentExists(componentId, componentType, componentParametersView); if (shouldLockComp) { // lock the component lockComponent(component, CREATE_OUTPUT); @@ -161,7 +168,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { final List outputsToCreate) { final Map outputsToPersist = MapUtil.toMap(outputsToCreate, OutputDefinition::getName); assignOwnerIdToOutputs(userId, outputsToPersist); - return toscaOperationFacade.addOutputsToComponent(outputsToPersist, cmptId).left().map(persistedOutputs -> outputsToCreate); + final var statusEither = toscaOperationFacade.addOutputsToComponent(outputsToPersist, cmptId); + if (statusEither.isRight()) { + return statusEither; + } + return statusEither.left().map(persistedOutputs -> outputsToCreate); } private void assignOwnerIdToOutputs(final String userId, final Map outputsToCreate) { @@ -189,7 +200,6 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { * @return */ public OutputDefinition deleteOutput(final String componentId, final String userId, final String outputId) { - Either deleteEither = null; if (log.isDebugEnabled()) { log.debug("Going to delete output id: {}", outputId); } @@ -236,4 +246,62 @@ public class OutputsBusinessLogic extends BaseBusinessLogic { unlockComponent(failed, component); } } + + public Either, ResponseFormat> createOutputsInGraph(final Map outputs, + final Component component, + final String userId) { + + final List result = new ArrayList<>(); + for (final Map.Entry outputDefinition : outputs.entrySet()) { + final var outputDefinitionValue = outputDefinition.getValue(); + outputDefinitionValue.setName(outputDefinition.getKey()); + + final String value = outputDefinitionValue.getValue(); + if (value != null) { + final List getAttribute = (List) ImportUtils.loadYamlAsStrictMap(value) + .get(ToscaGetFunctionType.GET_ATTRIBUTE.getFunctionName()); + if (getAttribute.size() == 2) { + final var optionalComponentInstance = component.getComponentInstanceByName(getAttribute.get(0)); + if (optionalComponentInstance.isPresent()) { + final var createdOutputs + = createOutputs(component.getUniqueId(), userId, getAttribute.get(1), optionalComponentInstance.get()); + if (createdOutputs.isRight()) { + return Either.right((createdOutputs.right().value())); + } + result.addAll(createdOutputs.left().value()); + } else { + // From SELF + outputDefinitionValue.setInstanceUniqueId(component.getUniqueId()); + } + } + } + } + return Either.left(result); + + } + + private Either, ResponseFormat> createOutputs(final String componentUniqueId, final String userId, + final String attributeName, + final ComponentInstance componentInstance) { + // From Instance + final List result = new ArrayList<>(); + final var componentInstanceAttributes = componentInstance.getAttributes(); + if (CollectionUtils.isNotEmpty(componentInstanceAttributes)) { + final var componentInstanceAttributeOptional = componentInstanceAttributes.stream() + .filter(ad -> ad.getName().equals(attributeName)).map(ComponentInstanceAttribute::new).findFirst(); + if (componentInstanceAttributeOptional.isPresent()) { + final var componentInstOutputsMap = new ComponentInstOutputsMap(); + componentInstOutputsMap.setComponentInstanceAttributes(Collections.singletonMap(componentInstance.getUniqueId(), + Collections.singletonList(new ComponentInstanceAttribOutput(componentInstanceAttributeOptional.get())))); + final var createdOutputs = createMultipleOutputs(userId, componentUniqueId, ComponentTypeEnum.SERVICE, + componentInstOutputsMap, true, false); + if (createdOutputs.isRight()) { + return Either.right((createdOutputs.right().value())); + } + result.addAll(createdOutputs.left().value()); + } + } + return Either.left(result); + } + } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java index 34460f46d5..3c21ae16a7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java @@ -97,6 +97,7 @@ import org.openecomp.sdc.be.model.LifeCycleTransitionEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.NodeTypeInfo; import org.openecomp.sdc.be.model.Operation; +import org.openecomp.sdc.be.model.OutputDefinition; import org.openecomp.sdc.be.model.ParsedToscaYamlInfo; import org.openecomp.sdc.be.model.PolicyDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; @@ -252,7 +253,7 @@ public class ServiceImportBusinessLogic { throw new ComponentException(findNodeTypesArtifactsToHandleRes.right().value()); } return createServiceFromYaml(service, csarInfo.getMainTemplateContent(), csarInfo.getMainTemplateName(), nodeTypesInfo, csarInfo, - findNodeTypesArtifactsToHandleRes.left().value(), true, false, null); + findNodeTypesArtifactsToHandleRes.left().value(), true, false, null, user.getUserId()); } catch (Exception e) { log.debug("Exception occured when createServiceFromCsar,error is:{}", e.getMessage(), e); throw new ComponentException(ActionStatus.GENERAL_ERROR); @@ -262,7 +263,8 @@ public class ServiceImportBusinessLogic { protected Service createServiceFromYaml(Service service, String topologyTemplateYaml, String yamlName, Map nodeTypesInfo, CsarInfo csarInfo, Map>> nodeTypesArtifactsToCreate, - boolean shouldLock, boolean inTransaction, String nodeName) throws BusinessLogicException { + boolean shouldLock, boolean inTransaction, String nodeName, final String userId) + throws BusinessLogicException { List createdArtifacts = new ArrayList<>(); Service createdService; CreateServiceFromYamlParameter csfyp = new CreateServiceFromYamlParameter(); @@ -277,7 +279,7 @@ public class ServiceImportBusinessLogic { csfyp.setNodeTypesInfo(nodeTypesInfo); csfyp.setCsarInfo(csarInfo); csfyp.setNodeName(nodeName); - createdService = createServiceAndRIsFromYaml(service, false, nodeTypesArtifactsToCreate, shouldLock, inTransaction, csfyp); + createdService = createServiceAndRIsFromYaml(service, false, nodeTypesArtifactsToCreate, shouldLock, inTransaction, csfyp, userId); log.debug("#createResourceFromYaml - The resource {} has been created ", service.getName()); } catch (ComponentException | BusinessLogicException e) { log.debug("Create Service from yaml failed", e); @@ -291,7 +293,8 @@ public class ServiceImportBusinessLogic { protected Service createServiceAndRIsFromYaml(Service service, boolean isNormative, Map>> nodeTypesArtifactsToCreate, - boolean shouldLock, boolean inTransaction, CreateServiceFromYamlParameter csfyp) + boolean shouldLock, boolean inTransaction, CreateServiceFromYamlParameter csfyp, + final String userId) throws BusinessLogicException { List nodeTypesNewCreatedArtifacts = new ArrayList<>(); String yamlName = csfyp.getYamlName(); @@ -325,7 +328,7 @@ public class ServiceImportBusinessLogic { log.trace("************* Going to add inputs from yaml {}", yamlName); Map inputs = parsedToscaYamlInfo.getInputs(); service = serviceImportParseLogic.createInputsOnService(service, inputs); - log.trace("************* Finish to add inputs from yaml {}", yamlName); + log.trace("************* Finished to add inputs from yaml {}", yamlName); ListDataDefinition substitutionFilterProperties = parsedToscaYamlInfo.getSubstitutionFilterProperties(); service = serviceImportParseLogic.createSubstitutionFilterOnService(service, substitutionFilterProperties); log.trace("************* Added Substitution filter from interface yaml {}", yamlName); @@ -334,6 +337,11 @@ public class ServiceImportBusinessLogic { service = createRIAndRelationsFromYaml(yamlName, service, uploadComponentInstanceInfoMap, topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName); log.trace("************* Finished to create nodes, RI and Relation from yaml {}", yamlName); + log.trace("************* Going to add outputs from yaml {}", yamlName); + Map outputs = parsedToscaYamlInfo.getOutputs(); + service = serviceImportParseLogic.createOutputsOnService(service, outputs, userId); + log.trace("************* Finished to add outputs from yaml {}", yamlName); + Either, ResponseFormat> validateUpdateVfGroupNamesRes = groupBusinessLogic.validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), service.getSystemName()); if (validateUpdateVfGroupNamesRes.isRight()) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java index 7a5b90976f..507f4ad32c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java @@ -77,6 +77,7 @@ import org.openecomp.sdc.be.model.LifeCycleTransitionEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.NodeTypeInfo; import org.openecomp.sdc.be.model.Operation; +import org.openecomp.sdc.be.model.OutputDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.RelationshipImpl; import org.openecomp.sdc.be.model.RelationshipInfo; @@ -112,7 +113,6 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; -import org.springframework.beans.factory.annotation.Autowired; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -131,27 +131,18 @@ public class ServiceImportParseLogic { private static final String CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES = "Create Resource - validateCapabilityTypesCreate"; private static final String CATEGORY_IS_EMPTY = "Resource category is empty"; private static final Logger log = Logger.getLogger(ServiceImportParseLogic.class); - @Autowired private final ServiceBusinessLogic serviceBusinessLogic; - @Autowired private final ComponentsUtils componentsUtils; - @Autowired private final ToscaOperationFacade toscaOperationFacade; - @Autowired private final LifecycleBusinessLogic lifecycleBusinessLogic; - @Autowired private final InputsBusinessLogic inputsBusinessLogic; - @Autowired private final ResourceImportManager resourceImportManager; - @Autowired private final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic; - @Autowired private final IInterfaceLifecycleOperation interfaceTypeOperation; - @Autowired private final ICapabilityTypeOperation capabilityTypeOperation; - @Autowired private final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic; private final GroupBusinessLogic groupBusinessLogic; + private final OutputsBusinessLogic outputsBusinessLogic; public ServiceImportParseLogic(final ServiceBusinessLogic serviceBusinessLogic, final ComponentsUtils componentsUtils, final ToscaOperationFacade toscaOperationFacade, final LifecycleBusinessLogic lifecycleBusinessLogic, @@ -159,7 +150,7 @@ public class ServiceImportParseLogic { final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic, final IInterfaceLifecycleOperation interfaceTypeOperation, final ICapabilityTypeOperation capabilityTypeOperation, final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic, - final GroupBusinessLogic groupBusinessLogic) { + final GroupBusinessLogic groupBusinessLogic, final OutputsBusinessLogic outputsBusinessLogic) { this.serviceBusinessLogic = serviceBusinessLogic; this.componentsUtils = componentsUtils; this.toscaOperationFacade = toscaOperationFacade; @@ -171,6 +162,7 @@ public class ServiceImportParseLogic { this.capabilityTypeOperation = capabilityTypeOperation; this.componentNodeFilterBusinessLogic = componentNodeFilterBusinessLogic; this.groupBusinessLogic = groupBusinessLogic; + this.outputsBusinessLogic = outputsBusinessLogic; } public Either>>, ResponseFormat> findNodeTypesArtifactsToHandle( @@ -1039,8 +1031,6 @@ public class ServiceImportParseLogic { reqDef.setLeftOccurrences(String.valueOf(left)); validRegDef = reqDef; break; - } else { - continue; } } else { validRegDef = reqDef; @@ -1066,8 +1056,6 @@ public class ServiceImportParseLogic { reqDef.setLeftOccurrences(String.valueOf(left)); validRegDef = reqDef; break; - } else { - continue; } } else { validRegDef = reqDef; @@ -1371,6 +1359,24 @@ public class ServiceImportParseLogic { return updatedResource.left().value(); } + public Service createOutputsOnService(final Service service, final Map outputs, final String userId) { + if (MapUtils.isNotEmpty(outputs) || isNotEmpty(service.getOutputs())) { + final Either, ResponseFormat> createOutputs = outputsBusinessLogic.createOutputsInGraph(outputs, service, userId); + if (createOutputs.isRight()) { + throw new ComponentException(createOutputs.right().value()); + } + } else { + return service; + } + final Either updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId()); + if (updatedResource.isRight()) { + throw new ComponentException( + componentsUtils.getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, + ComponentTypeEnum.SERVICE)); + } + return updatedResource.left().value(); + } + public Service createSubstitutionFilterOnService(Service service, ListDataDefinition substitutionFilterProperties) throws BusinessLogicException { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java index 7c300b310d..1b1111a86e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java @@ -1061,16 +1061,16 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet { } } - protected void handleImportService(Wrapper responseWrapper, User user, UploadServiceInfo serviceInfoObject, String yamlAsString, - ServiceAuthorityTypeEnum authority, boolean createNewVersion, String serviceUniqueId) throws ZipException { + protected void handleImportService(Wrapper responseWrapper, User user, UploadServiceInfo serviceInfoObject, String serviceUniqueId) + throws ZipException { Response response = null; - Object representation = null; ImmutablePair importedServiceStatus = null; if (CsarValidationUtils.isCsarPayloadName(serviceInfoObject.getPayloadName())) { log.debug("import service from csar"); importedServiceStatus = importServiceFromUICsar(serviceInfoObject, user, serviceUniqueId); } if (importedServiceStatus != null) { + Object representation = null; try { representation = RepresentationUtils.toRepresentation(importedServiceStatus.left); } catch (IOException e) { @@ -1083,18 +1083,14 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet { private ImmutablePair importServiceFromUICsar(UploadServiceInfo serviceInfoObject, User user, String serviceUniqueId) throws ZipException { - Service newService; - ImmutablePair result = null; - ActionStatus actionStatus; Service service = new Service(); String payloadName = serviceInfoObject.getPayloadName(); fillServiceFromServiceInfoObject(service, serviceInfoObject); Map csarUIPayloadRes = getCsarFromPayload(serviceInfoObject); getAndValidateCsarYaml(csarUIPayloadRes, service, user, payloadName); - newService = serviceImportManager.getServiceImportBusinessLogic() + final Service newService = serviceImportManager.getServiceImportBusinessLogic() .createService(service, AuditingActionEnum.CREATE_SERVICE, user, csarUIPayloadRes, payloadName); - actionStatus = ActionStatus.CREATED; - return new ImmutablePair<>(newService, actionStatus); + return new ImmutablePair<>(newService, ActionStatus.CREATED); } private void fillServiceFromServiceInfoObject(Service service, UploadServiceInfo serviceInfoObject) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java index c26f3ca522..f49bfdc637 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java @@ -672,18 +672,17 @@ public class ServiceServlet extends AbstractValidationsServlet { } private Wrapper performUIImport(String data, final HttpServletRequest request, String userId, - String ServiceUniqueId) throws FileNotFoundException, ZipException { + String serviceUniqueId) throws FileNotFoundException, ZipException { Wrapper responseWrapper = new Wrapper<>(); Wrapper userWrapper = new Wrapper<>(); Wrapper uploadServiceInfoWrapper = new Wrapper<>(); Wrapper yamlStringWrapper = new Wrapper<>(); - ServiceAuthorityTypeEnum ServiceAuthorityEnum = ServiceAuthorityTypeEnum.USER_TYPE_UI; - commonServiceGeneralValidations(responseWrapper, userWrapper, uploadServiceInfoWrapper, ServiceAuthorityEnum, userId, data); + ServiceAuthorityTypeEnum serviceAuthorityTypeEnum = ServiceAuthorityTypeEnum.USER_TYPE_UI; + commonServiceGeneralValidations(responseWrapper, userWrapper, uploadServiceInfoWrapper, serviceAuthorityTypeEnum, userId, data); specificServiceAuthorityValidations(responseWrapper, uploadServiceInfoWrapper, yamlStringWrapper, userWrapper.getInnerElement(), request, - data, ServiceAuthorityEnum); + data, serviceAuthorityTypeEnum); if (responseWrapper.isEmpty()) { - handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(), - yamlStringWrapper.getInnerElement(), ServiceAuthorityEnum, true, ServiceUniqueId); + handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(), serviceUniqueId); } return responseWrapper; } @@ -775,8 +774,7 @@ public class ServiceServlet extends AbstractValidationsServlet { uploadServiceInfoWrapper.getInnerElement().setProjectCode(oldService.getProjectCode()); if (responseWrapper.isEmpty()) { log.debug("importReplaceService:start handleImportService"); - handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(), - yamlStringWrapper.getInnerElement(), serviceAuthorityEnum, true, null); + handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(), null); } return responseWrapper.getInnerElement(); } catch (IOException | ZipException e) { -- cgit 1.2.3-korg