aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java65
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java88
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java300
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java252
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java53
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/PolicyServlet.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java113
11 files changed, 451 insertions, 460 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index 6752586b80..31281db0c7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -87,6 +87,7 @@ import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementSubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupTypeDefinition;
@@ -96,7 +97,6 @@ import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PolicyTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.UploadArtifactInfo;
import org.openecomp.sdc.be.model.UploadCapInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
@@ -105,13 +105,12 @@ import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.utils.TypeUtils;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.parser.ParserException;
/**
* A handler class designed to parse the YAML file of the service template for a JAVA object
*/
-@Component
+@org.springframework.stereotype.Component
public class YamlTemplateParsingHandler {
private static final Pattern propertyValuePattern = Pattern.compile("[ ]*\\{[ ]*(str_replace=|token=|get_property=|concat=|get_attribute=)+");
@@ -134,7 +133,7 @@ public class YamlTemplateParsingHandler {
public ParsedToscaYamlInfo parseResourceInfoFromYAML(String fileName, String resourceYml, Map<String, String> createdNodesToscaResourceNames,
Map<String, NodeTypeInfo> nodeTypesInfo, String nodeName,
- org.openecomp.sdc.be.model.Component component, String interfaceTemplateYaml) {
+ Component component, String interfaceTemplateYaml) {
log.debug("#parseResourceInfoFromYAML - Going to parse yaml {} ", fileName);
Map<String, Object> mappedToscaTemplate = getMappedToscaTemplate(fileName, resourceYml, nodeTypesInfo, nodeName);
ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
@@ -145,15 +144,14 @@ public class YamlTemplateParsingHandler {
parsedToscaYamlInfo.setInputs(getInputs(mappedTopologyTemplateInputs));
parsedToscaYamlInfo.setInstances(getInstances(mappedToscaTemplate, createdNodesToscaResourceNames));
parsedToscaYamlInfo.setGroups(getGroups(mappedToscaTemplate, component.getModel()));
- if (component instanceof Resource) {
- parsedToscaYamlInfo.setPolicies(getPolicies(fileName, mappedToscaTemplate, component.getModel()));
- }
- if (getSubstitutionMappings(mappedToscaTemplate) != null) {
+ parsedToscaYamlInfo.setPolicies(getPolicies(mappedToscaTemplate, component.getModel()));
+ Map<String, Object> substitutionMappings = getSubstitutionMappings(mappedToscaTemplate);
+ if (substitutionMappings != null) {
if (component.isService() && !interfaceTemplateYaml.isEmpty()) {
parsedToscaYamlInfo.setProperties(getProperties(loadYamlAsStrictMap(interfaceTemplateYaml)));
parsedToscaYamlInfo.setSubstitutionFilterProperties(getSubstitutionFilterProperties(mappedToscaTemplate));
}
- parsedToscaYamlInfo.setSubstitutionMappingNodeType((String) getSubstitutionMappings(mappedToscaTemplate).get(NODE_TYPE.getElementName()));
+ parsedToscaYamlInfo.setSubstitutionMappingNodeType((String) substitutionMappings.get(NODE_TYPE.getElementName()));
}
log.debug("#parseResourceInfoFromYAML - The yaml {} has been parsed ", fileName);
return parsedToscaYamlInfo;
@@ -230,10 +228,13 @@ public class YamlTemplateParsingHandler {
return constraints;
}
- private Map<String, PolicyDefinition> getPolicies(String fileName, Map<String, Object> toscaJson, String model) {
- Map<String, Object> foundPolicies = findFirstToscaMapElement(toscaJson, POLICIES).left().on(err -> logPoliciesNotFound(fileName));
+ private Map<String, PolicyDefinition> getPolicies(Map<String, Object> toscaJson, String model) {
+ Map<String, Object> mappedTopologyTemplate = (Map<String, Object>) findToscaElement(toscaJson, TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL)
+ .left().on(err -> new HashMap<>());
+ Map<String, Object> foundPolicies = (Map<String, Object>) mappedTopologyTemplate.get(POLICIES.getElementName());
if (MapUtils.isNotEmpty(foundPolicies)) {
- return foundPolicies.entrySet().stream().map(policyToCreate -> createPolicy(policyToCreate, model)).collect(Collectors.toMap(PolicyDefinition::getName, p -> p));
+ return foundPolicies.entrySet().stream().map(policyToCreate -> createPolicy(policyToCreate, model))
+ .collect(Collectors.toMap(PolicyDefinition::getName, p -> p));
}
return Collections.emptyMap();
}
@@ -257,11 +258,6 @@ public class YamlTemplateParsingHandler {
return emptyPolicyDef;
}
- private Map<String, Object> logPoliciesNotFound(String fileName) {
- log.debug("#logPoliciesNotFound - Policies were not found in the yaml template {}.", fileName);
- return Collections.emptyMap();
- }
-
private void validateAndFillPolicy(PolicyDefinition emptyPolicyDefinition, Map<String, Object> policyTemplateJsonMap, String model) {
String policyTypeName = (String) policyTemplateJsonMap.get(TYPE.getElementName());
if (StringUtils.isEmpty(policyTypeName)) {
@@ -364,25 +360,6 @@ public class YamlTemplateParsingHandler {
return new HashMap<>();
}
- private boolean matcheKey(Map<String, Object> foundGroups) {
- if (foundGroups != null && !foundGroups.isEmpty()) {
- for (Map.Entry<String, Object> stringObjectEntry : foundGroups.entrySet()) {
- String key = stringObjectEntry.getKey();
- if (key.contains("group")) {
- if (foundGroups.get(key) instanceof Map) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- private Map<String, Object> logGroupsNotFound(String fileName) {
- log.debug("#logGroupsNotFound - Groups were not found in the yaml template {}.", fileName);
- return new HashMap<>();
- }
-
private void updateCapabilitiesNames(GroupDefinition group, Map<String, String> capabilityNames) {
if (MapUtils.isNotEmpty(group.getCapabilities())) {
group.getCapabilities().values().stream().flatMap(Collection::stream).filter(cap -> capabilityNames.containsKey(cap.getName()))
@@ -593,7 +570,7 @@ public class YamlTemplateParsingHandler {
if (CollectionUtils.isNotEmpty(missingProperties)) {
if (log.isDebugEnabled()) {
log.debug("#validateProperties - Failed to validate properties. The properties {} are missing on {} of the type {}. ",
- missingProperties.toString(), name, type);
+ missingProperties.toString(), name, type);
}
rollbackWithException(actionStatus, missingProperties.toString(), missingProperties.toString(), name, type);
}
@@ -1045,7 +1022,7 @@ public class YamlTemplateParsingHandler {
@SuppressWarnings("unchecked")
private void findAndFillInputRecursively(Map<String, Object> propValue, UploadPropInfo propertyDef) {
- for (Map.Entry<String,Object> entry : propValue.entrySet()) {
+ for (Map.Entry<String, Object> entry : propValue.entrySet()) {
String propName = entry.getKey();
Object value = entry.getValue();
if (value instanceof Map) {
@@ -1057,9 +1034,7 @@ public class YamlTemplateParsingHandler {
}
private void fillInputsRecursively(UploadPropInfo propertyDef, String propName, List<Object> inputs) {
- inputs.stream()
- .filter(Map.class::isInstance)
- .forEach(o -> fillInputRecursively(propName, (Map<String, Object>) o, propertyDef));
+ inputs.stream().filter(Map.class::isInstance).forEach(o -> fillInputRecursively(propName, (Map<String, Object>) o, propertyDef));
}
@SuppressWarnings("unchecked")
@@ -1102,8 +1077,8 @@ public class YamlTemplateParsingHandler {
private void failOnMissingCapabilityTypes(GroupDefinition groupDefinition, List<String> missingCapTypes) {
if (log.isDebugEnabled()) {
log.debug(
- "#failOnMissingCapabilityTypes - Failed to validate the capabilities of the group {}. The capability types {} are missing on the group type {}. ",
- groupDefinition.getName(), missingCapTypes.toString(), groupDefinition.getType());
+ "#failOnMissingCapabilityTypes - Failed to validate the capabilities of the group {}. The capability types {} are missing on the group type {}. ",
+ groupDefinition.getName(), missingCapTypes.toString(), groupDefinition.getType());
}
if (CollectionUtils.isNotEmpty(missingCapTypes)) {
rollbackWithException(ActionStatus.MISSING_CAPABILITY_TYPE, missingCapTypes.toString());
@@ -1113,8 +1088,8 @@ public class YamlTemplateParsingHandler {
private void failOnMissingCapabilityNames(GroupDefinition groupDefinition, List<String> missingCapNames) {
if (log.isDebugEnabled()) {
log.debug(
- "#failOnMissingCapabilityNames - Failed to validate the capabilities of the group {}. The capabilities with the names {} are missing on the group type {}. ",
- groupDefinition.getName(), missingCapNames.toString(), groupDefinition.getType());
+ "#failOnMissingCapabilityNames - Failed to validate the capabilities of the group {}. The capabilities with the names {} are missing on the group type {}. ",
+ groupDefinition.getName(), missingCapNames.toString(), groupDefinition.getType());
}
rollbackWithException(ActionStatus.MISSING_CAPABILITIES, missingCapNames.toString(), CapabilityDataDefinition.OwnerType.GROUP.getValue(),
groupDefinition.getName());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 4268d91dc9..a1f28299a1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -42,9 +42,9 @@ import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
@@ -579,7 +579,7 @@ public abstract class BaseBusinessLogic {
DataTypeDefinition dataTypeDefinition = dataTypes.get(propertyType);
if (dataTypeDefinition == null) {
log.debug(INVALID_PROPERTY_TYPE, propertyType);
- return Either.right(false);
+ return Either.right(false);
}
ImmutablePair<JsonElement, Boolean> validateResult = dataTypeValidatorConverter
.validateAndUpdate(value, dataTypeDefinition, dataTypes);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 6625d72bcf..4372564bbd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -104,6 +104,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
private static final Logger log = Logger.getLogger(ComponentBusinessLogic.class.getName());
+
protected final GroupBusinessLogic groupBusinessLogic;
protected ArtifactsBusinessLogic artifactsBusinessLogic;
protected GenericTypeBusinessLogic genericTypeBusinessLogic;
@@ -432,8 +433,9 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
Either<List<Component>, StorageOperationStatus> nonCheckoutCompResponse = null;
try {
validateUserExists(userId);
- nonCheckoutCompResponse = toscaOperationFacade
- .getLatestVersionNotAbstractMetadataOnly(isAbstractAbstract, componentTypeEnum, internalComponentType, modelName, includeNormativeExtensionModels);
+ nonCheckoutCompResponse = toscaOperationFacade
+ .getLatestVersionNotAbstractMetadataOnly(isAbstractAbstract, componentTypeEnum, internalComponentType, modelName,
+ includeNormativeExtensionModels);
if (nonCheckoutCompResponse.isLeft()) {
log.debug("Retrieved Resource successfully.");
return Either.left(nonCheckoutCompResponse.left().value());
@@ -441,7 +443,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
return Either
.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(nonCheckoutCompResponse.right().value())));
} finally {
- if(nonCheckoutCompResponse != null && nonCheckoutCompResponse.isLeft() ) {
+ if (nonCheckoutCompResponse != null && nonCheckoutCompResponse.isLeft()) {
janusGraphDao.commit();
}
}
@@ -547,7 +549,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
final ArtifactDefinition csarArtifact = component.getToscaArtifacts().values().stream()
.filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType())).findAny().orElseThrow(() -> {
throw new ByResponseFormatComponentException(
- componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, ArtifactTypeEnum.TOSCA_CSAR.name()));
+ componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, ArtifactTypeEnum.TOSCA_CSAR.name()));
});
return artifactsBusinessLogic.handleDownloadToscaModelRequest(component, csarArtifact);
}
@@ -691,7 +693,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
});
return componentNonGenericInputs;
}
-
+
protected void generatePropertiesFromGenericType(final Component component, final Resource genericType) {
if (CollectionUtils.isEmpty(genericType.getProperties())) {
return;
@@ -708,6 +710,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
component.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(null));
}
+
protected <T extends Component> Resource fetchAndSetDerivedFromGenericType(final T component) {
return fetchAndSetDerivedFromGenericType(component, null);
}
@@ -916,7 +919,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
if (validPropertiesMerge.isRight()) {
if (log.isDebugEnabled()) {
log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic",
- validPropertiesMerge.right().value());
+ validPropertiesMerge.right().value());
}
return false;
}
@@ -926,7 +929,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
if (validAttributesMerge.isRight()) {
if (log.isDebugEnabled()) {
log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic",
- validAttributesMerge.right().value());
+ validAttributesMerge.right().value());
}
return false;
}
@@ -998,7 +1001,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
protected Either<Component, ResponseFormat> updateCatalog(Component component, ChangeTypeEnum changeStatus) {
if (log.isDebugEnabled()) {
log.debug("update Catalog start with Component Type {} And Componet Name {} with change status {}",
- component.getComponentType().name(),component.getName(), changeStatus.name());
+ component.getComponentType().name(), component.getName(), changeStatus.name());
}
ActionStatus status = catalogOperations.updateCatalog(changeStatus, component);
if (status != ActionStatus.OK) {
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 3a1c55a31f..7719187cda 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
@@ -177,10 +177,9 @@ public final class ImportUtils {
public static Either<Object, ResultStatusEnum> findToscaElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementName,
ToscaElementTypeEnum elementType) {
- List<Object> foundElements = new ArrayList<>();
- findToscaElements(toscaJson, elementName.getElementName(), elementType, foundElements);
- if (!isEmpty(foundElements)) {
- return Either.left(foundElements.get(0));
+ final var toscaElements = findToscaElements(toscaJson, elementName.getElementName(), elementType, new ArrayList<>());
+ if (toscaElements.isLeft() && CollectionUtils.isNotEmpty(toscaElements.left().value())) {
+ return Either.left(toscaElements.left().value().get(0));
}
return Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java
index f8aab3def1..2f01ef3ecc 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogic.java
@@ -46,6 +46,7 @@ import org.openecomp.sdc.be.components.property.PropertyDeclarationOrchestrator;
import org.openecomp.sdc.be.components.validation.PolicyUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.GetPolicyValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -125,33 +126,32 @@ public class PolicyBusinessLogic extends BaseBusinessLogic {
}
}
- public Map<String, PolicyDefinition> createPoliciesFromParsedCsar(Component component,
- final Map<String, PolicyDefinition> incomingPolicyDefinitions) {
+ public Map<String, PolicyDefinition> createPolicies(final Component component,
+ final Map<String, PolicyDefinition> incomingPolicyDefinitions) {
if (MapUtils.isEmpty(incomingPolicyDefinitions)) {
return Collections.emptyMap();
}
- Map<String, PolicyDefinition> createdPolicies = new HashMap<>();
- for (Map.Entry<String, PolicyDefinition> policyEntry : incomingPolicyDefinitions.entrySet()) {
- PolicyDefinition incomingPolicyDefinition = policyEntry.getValue();
- String policyName = incomingPolicyDefinition.getName();
+ final Map<String, PolicyDefinition> createdPolicies = new HashMap<>();
+ for (final PolicyDefinition incomingPolicyDefinition : incomingPolicyDefinitions.values()) {
+ final String policyName = incomingPolicyDefinition.getName();
log.trace("Going to create policy {}", incomingPolicyDefinition);
loggerSupportability
.log(LoggerSupportabilityActions.CREATE_GROUP_POLICY, component.getComponentMetadataForSupportLog(), StatusCode.STARTED,
"Start to create policy: {} for component {}", policyName, component.getName());
- String policyType = incomingPolicyDefinition.getType();
+ final String policyType = incomingPolicyDefinition.getType();
if (StringUtils.isEmpty(policyType)) {
log.debug("Policy type '{}' for policy '{}' not found.", policyType, policyName);
throw new ByActionStatusComponentException(ActionStatus.POLICY_MISSING_POLICY_TYPE, policyName);
}
// create policyDefinition
- String policyTypeName = incomingPolicyDefinition.getPolicyTypeName();
+ final String policyTypeName = incomingPolicyDefinition.getPolicyTypeName();
PolicyDefinition createdPolicyDefinition = createPolicy(policyTypeName, component);
// set isFromCsar
createdPolicyDefinition.setToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR, true);
// link policy to component
component.addPolicy(createdPolicyDefinition);
// process targets
- Map<PolicyTargetType, List<String>> policyTargets = incomingPolicyDefinition.getTargets();
+ final Map<PolicyTargetType, List<String>> policyTargets = incomingPolicyDefinition.getTargets();
createdPolicyDefinition = setUpdatePolicyTargets(component, createdPolicyDefinition, policyTargets);
// process policy properties
List<PropertyDataDefinition> properties = incomingPolicyDefinition.getProperties();
@@ -179,38 +179,60 @@ public class PolicyBusinessLogic extends BaseBusinessLogic {
if (MapUtils.isEmpty(targets)) {
return policyDefinition;
}
- List<String> targetsToUpdate = targets.get(PolicyTargetType.COMPONENT_INSTANCES);
- if (CollectionUtils.isEmpty(targetsToUpdate)) {
+ final List<String> componentInstancesTargetsToUpdate = targets.get(PolicyTargetType.COMPONENT_INSTANCES);
+ final List<String> groupsTargetsToUpdate = targets.get(PolicyTargetType.GROUPS);
+ if (CollectionUtils.isEmpty(componentInstancesTargetsToUpdate) && CollectionUtils.isEmpty(groupsTargetsToUpdate)) {
return policyDefinition;
}
+
+ final List<String> allTargets = joinLists(componentInstancesTargetsToUpdate, groupsTargetsToUpdate);
+
// update targets to uniqueIds of respective component instance
- List<String> targetsUniqueIds = new ArrayList<>();
- for (String targetName : targetsToUpdate) {
- Optional<ComponentInstance> componentInstance = component.getComponentInstanceByName(targetName);
- String componentUniqueId = componentInstance
- .orElseThrow(() -> new ByActionStatusComponentException(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND)).getUniqueId();
- targetsUniqueIds.add(componentUniqueId);
- }
- EnumMap<PolicyTargetType, List<String>> updatedTargets = new EnumMap<>(PolicyTargetType.class);
- updatedTargets.put(PolicyTargetType.COMPONENT_INSTANCES, targetsUniqueIds);
+ final List<String> targetsGroupsUniqueIds = new ArrayList<>();
+ final List<String> targetsInstanceUniqueIds = new ArrayList<>();
+ for (final String targetName : allTargets) {
+ final String groupsTargetUniqueIdForTargetName = getTargetGroupUniqueIdByTargetName(component, targetName);
+ if (groupsTargetUniqueIdForTargetName != null) {
+ targetsGroupsUniqueIds.add(groupsTargetUniqueIdForTargetName);
+ }
+ final String instanceTargetUniqueIdForTargetName = getTargetInstanceUniqueIdByTargetName(component, targetName);
+ if (instanceTargetUniqueIdForTargetName != null) {
+ targetsInstanceUniqueIds.add(instanceTargetUniqueIdForTargetName);
+ }
+ }
+ if (targetsGroupsUniqueIds.isEmpty() && targetsInstanceUniqueIds.isEmpty()) {
+ throw new ByActionStatusComponentException(ActionStatus.POLICY_TARGET_DOES_NOT_EXIST);
+ }
+ final EnumMap<PolicyTargetType, List<String>> updatedTargets = new EnumMap<>(PolicyTargetType.class);
+ if (!targetsGroupsUniqueIds.isEmpty()) {
+ updatedTargets.put(PolicyTargetType.GROUPS, targetsGroupsUniqueIds);
+ }
+ if (!targetsInstanceUniqueIds.isEmpty()) {
+ updatedTargets.put(PolicyTargetType.COMPONENT_INSTANCES, targetsInstanceUniqueIds);
+ }
policyDefinition.setTargets(updatedTargets);
- policyDefinition = validateAndUpdatePolicyTargets(component, policyDefinition.getUniqueId(), policyDefinition.getTargets());
- return policyDefinition;
+ return validateAndUpdatePolicyTargets(component, policyDefinition.getUniqueId(), policyDefinition.getTargets());
}
- public Either<List<PolicyDefinition>, ResponseFormat> getPoliciesList(ComponentTypeEnum componentType, String componentId, String userId) {
- Either<List<PolicyDefinition>, ResponseFormat> result;
- log.trace("#getPolicies - starting to retrieve policies of component {}. ", componentId);
- try {
- Component component = validateContainerComponentAndUserBeforeReadOperation(componentType, componentId, userId);
- result = Either.left(component.resolvePoliciesList());
- } catch (Exception e) {
- log.error("#getPolicy - the exception occurred upon retrieving policies list of component {}: ", componentId, e);
- result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+ private List<String> joinLists(final List<String> a, final List<String> b) {
+ final List<String> result = new ArrayList<>();
+ if (CollectionUtils.isNotEmpty(a)) {
+ result.addAll(a);
+ }
+ if (CollectionUtils.isNotEmpty(b)) {
+ result.addAll(b);
}
return result;
}
+ private String getTargetGroupUniqueIdByTargetName(final Component component, final String targetName) {
+ return component.getGroupByInvariantName(targetName).map(GroupDataDefinition::getUniqueId).orElse(null);
+ }
+
+ private String getTargetInstanceUniqueIdByTargetName(final Component component, final String targetName) {
+ return component.getComponentInstanceByName(targetName).map(ComponentInstance::getUniqueId).orElse(null);
+ }
+
/**
* Retrieves the policy of the component by UniqueId
*
@@ -266,7 +288,6 @@ public class PolicyBusinessLogic extends BaseBusinessLogic {
* @return a policy or an error in a response format
*/
public PolicyDefinition deletePolicy(ComponentTypeEnum componentType, String componentId, String policyId, String userId, boolean shouldLock) {
- PolicyDefinition result = null;
log.trace("#deletePolicy - starting to update the policy {} on the component {}. ", policyId, componentId);
Component component = null;
boolean failed = false;
@@ -358,7 +379,6 @@ public class PolicyBusinessLogic extends BaseBusinessLogic {
public PolicyDefinition updatePolicyTargets(ComponentTypeEnum componentTypeEnum, String componentId, String policyId,
Map<PolicyTargetType, List<String>> targets, String userId) {
- Either<PolicyDefinition, ResponseFormat> result = null;
log.debug("updating the policy id {} targets with the components {}. ", policyId, componentId);
boolean failed = false;
try {
@@ -554,7 +574,7 @@ public class PolicyBusinessLogic extends BaseBusinessLogic {
}
private PolicyTypeDefinition validatePolicyTypeOnCreatePolicy(String policyTypeName, Component component) {
- Either<PolicyTypeDefinition, StorageOperationStatus> latestPolicyTypeByType = policyTypeOperation.getLatestPolicyTypeByType(policyTypeName, component.getModel());
+ final var latestPolicyTypeByType = policyTypeOperation.getLatestPolicyTypeByType(policyTypeName, component.getModel());
if (latestPolicyTypeByType.isRight()) {
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(latestPolicyTypeByType.right().value()));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 6d5829e0fd..1f107e4ec1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -1762,7 +1762,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Resource createPoliciesOnResource(Resource resource, Map<String, PolicyDefinition> policies) {
- policyBusinessLogic.createPoliciesFromParsedCsar(resource, policies);
+ policyBusinessLogic.createPolicies(resource, policies);
return resource;
}
@@ -1929,7 +1929,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.addPropertyToComponent(propertyDefinition, resource);
if (addPropertyEither.isRight()) {
- final String error = String.format("failed to add properties from yaml: {}", addPropertyEither.right().value());
+ final String error = String.format("failed to add properties from yaml: %s", addPropertyEither.right().value());
loggerSupportability.log(LoggerSupportabilityActions.CREATE_PROPERTIES, resource.getComponentMetadataForSupportLog(),
StatusCode.ERROR,
error);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 8dac6ffc08..2cccc31ded 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -100,9 +100,9 @@ import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceDistributionReqInfo;
import org.openecomp.sdc.be.impl.ForwardingPathUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
@@ -119,12 +119,12 @@ import org.openecomp.sdc.be.model.GroupInstanceProperty;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ForwardingPathOperation;
@@ -184,22 +184,19 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
private final ServiceDistributionValidation serviceDistributionValidation;
private final ForwardingPathValidator forwardingPathValidator;
private final UiComponentDataConverter uiComponentDataConverter;
+ private final ModelOperation modelOperation;
+ private final ServiceRoleValidator serviceRoleValidator;
+ private final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator;
+ private final ServiceCategoryValidator serviceCategoryValidator;
+ private final ServiceValidator serviceValidator;
+ private final PolicyBusinessLogic policyBusinessLogic;
+ private final GroupBusinessLogic groupBusinessLogic;
private ForwardingPathOperation forwardingPathOperation;
private AuditCassandraDao auditCassandraDao;
private ServiceTypeValidator serviceTypeValidator;
private List<ServiceCreationPlugin> serviceCreationPluginList;
private ServiceFunctionValidator serviceFunctionValidator;
- @Autowired
- private ServiceRoleValidator serviceRoleValidator;
- @Autowired
- private ServiceInstantiationTypeValidator serviceInstantiationTypeValidator;
- @Autowired
- private ServiceCategoryValidator serviceCategoryValidator;
- @Autowired
- private ServiceValidator serviceValidator;
- private final ModelOperation modelOperation;
- @Autowired
public ServiceBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, IGroupInstanceOperation groupInstanceOperation,
IGroupTypeOperation groupTypeOperation, GroupBusinessLogic groupBusinessLogic, InterfaceOperation interfaceOperation,
InterfaceLifecycleOperation interfaceLifecycleTypeOperation, ArtifactsBusinessLogic artifactsBusinessLogic,
@@ -209,7 +206,11 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
ComponentContactIdValidator componentContactIdValidator, ComponentNameValidator componentNameValidator,
ComponentTagsValidator componentTagsValidator, ComponentValidator componentValidator,
ComponentIconValidator componentIconValidator, ComponentProjectCodeValidator componentProjectCodeValidator,
- ComponentDescriptionValidator componentDescriptionValidator, ModelOperation modelOperation) {
+ ComponentDescriptionValidator componentDescriptionValidator, ModelOperation modelOperation,
+ final ServiceRoleValidator serviceRoleValidator,
+ final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator,
+ final ServiceCategoryValidator serviceCategoryValidator, final ServiceValidator serviceValidator,
+ final PolicyBusinessLogic policyBusinessLogic) {
super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, interfaceOperation,
interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator);
@@ -219,6 +220,12 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
this.forwardingPathValidator = forwardingPathValidator;
this.uiComponentDataConverter = uiComponentDataConverter;
this.modelOperation = modelOperation;
+ this.serviceRoleValidator = serviceRoleValidator;
+ this.serviceInstantiationTypeValidator = serviceInstantiationTypeValidator;
+ this.serviceCategoryValidator = serviceCategoryValidator;
+ this.serviceValidator = serviceValidator;
+ this.policyBusinessLogic = policyBusinessLogic;
+ this.groupBusinessLogic = groupBusinessLogic;
}
@Autowired
@@ -637,16 +644,6 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return Either.left(archiveAudit);
}
- @VisibleForTesting
- public void setServiceValidator(ServiceValidator serviceValidator) {
- this.serviceValidator = serviceValidator;
- }
-
- @VisibleForTesting
- public void setServiceCategoryValidator(ServiceCategoryValidator serviceCategoryValidator) {
- this.serviceCategoryValidator = serviceCategoryValidator;
- }
-
private List<Map<String, Object>> getAuditingFieldsList(List<? extends AuditingGenericEvent> prevVerAuditList) {
List<Map<String, Object>> prevVerAudit = new ArrayList<>();
for (AuditingGenericEvent auditEvent : prevVerAuditList) {
@@ -666,7 +663,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
public Either<Service, ResponseFormat> createService(Service service, User user) {
// get user details
user = validateUser(user, "Create Service", service, AuditingActionEnum.CREATE_RESOURCE, false);
- log.debug("User returned from validation: " + user.toString());
+ log.debug("User returned from validation: {}", user);
// validate user role
validateUserRole(user, service, new ArrayList<>(), AuditingActionEnum.CREATE_RESOURCE, null);
service.setCreatorUserId(user.getUserId());
@@ -683,7 +680,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (createServiceResponse.isRight()) {
return createServiceResponse;
}
- return createServiceByDao(service, user).left().bind(c -> updateCatalog(c, ChangeTypeEnum.LIFECYCLE).left().map(r -> (Service) r));
+ return createServiceByDao(service, user).left().bind(c -> updateCatalog(c, ChangeTypeEnum.LIFECYCLE).left().map(Service.class::cast));
}
private void checkFieldsForOverideAttampt(Service service) {
@@ -863,14 +860,14 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
BeEcompErrorManager.getInstance().logBeSystemError("Update Service Metadata");
log.debug("failed to update sevice {}", serviceToUpdate.getUniqueId());
return (componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
- }).left().bind(c -> updateCatalogAndCommit(c));
+ }).left().bind(this::updateCatalogAndCommit);
} finally {
graphLockOperation.unlockComponent(serviceId, NodeTypeEnum.Service);
}
}
private Either<Service, ResponseFormat> updateCatalogAndCommit(Service service) {
- Either<Service, ResponseFormat> res = updateCatalog(service, ChangeTypeEnum.LIFECYCLE).left().map(s -> (Service) s);
+ Either<Service, ResponseFormat> res = updateCatalog(service, ChangeTypeEnum.LIFECYCLE).left().map(Service.class::cast);
janusGraphDao.commit();
return res;
}
@@ -1483,7 +1480,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
Boolean isServiceApi) {
ArtifactDefinition artifactInfo = artifactsBusinessLogic
.createArtifactPlaceHolderInfo(serviceId, logicalName, artifactInfoMap, user, ArtifactGroupTypeEnum.INFORMATIONAL);
- if (isServiceApi) {
+ if (Boolean.TRUE.equals(isServiceApi)) {
artifactInfo.setMandatory(false);
artifactInfo.setServiceApi(true);
}
@@ -1556,7 +1553,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return Either.right(response);
}
Service service = serviceRes.left().value();
- if (service.isArchived()) {
+ if (Boolean.TRUE.equals(service.isArchived())) {
log.info("Component is archived. Component id: {}", serviceId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_IS_ARCHIVED, service.getName()));
}
@@ -1658,123 +1655,6 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return asList;
}
- private List<GroupInstance> collectGroupsInstanceForCompInstance(ComponentInstance currVF) {
- Map<String, ArtifactDefinition> deploymentArtifacts = currVF.getDeploymentArtifacts();
- if (currVF.getGroupInstances() != null) {
- currVF.getGroupInstances().forEach(gi -> gi.alignArtifactsUuid(deploymentArtifacts));
- }
- return currVF.getGroupInstances();
- }
-
- private ArtifactDefinition getVfModuleInstArtifactForCompInstance(ComponentInstance currVF, Service service, Wrapper<String> payloadWrapper,
- Wrapper<ResponseFormat> responseWrapper) {
- ArtifactDefinition vfModuleAertifact = null;
- if (MapUtils.isNotEmpty(currVF.getDeploymentArtifacts())) {
- final Optional<ArtifactDefinition> optionalVfModuleArtifact = currVF.getDeploymentArtifacts().values().stream()
- .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.getType())).findAny();
- if (optionalVfModuleArtifact.isPresent()) {
- vfModuleAertifact = optionalVfModuleArtifact.get();
- }
- }
- if (vfModuleAertifact == null) {
- Either<ArtifactDefinition, ResponseFormat> createVfModuleArtifact = createVfModuleArtifact(currVF, service,
- payloadWrapper.getInnerElement());
- if (createVfModuleArtifact.isLeft()) {
- vfModuleAertifact = createVfModuleArtifact.left().value();
- } else {
- responseWrapper.setInnerElement(createVfModuleArtifact.right().value());
- }
- }
- return vfModuleAertifact;
- }
-
- private void fillVfModuleInstHeatEnvPayload(List<GroupInstance> groupsForCurrVF, Wrapper<String> payloadWrapper) {
- List<VfModuleArtifactPayload> vfModulePayloads = new ArrayList<>();
- if (groupsForCurrVF != null) {
- for (GroupInstance groupInstance : groupsForCurrVF) {
- VfModuleArtifactPayload modulePayload = new VfModuleArtifactPayload(groupInstance);
- vfModulePayloads.add(modulePayload);
- }
- vfModulePayloads.sort(VfModuleArtifactPayload::compareByGroupName);
- final Gson gson = new GsonBuilder().setPrettyPrinting().create();
- String vfModulePayloadString = gson.toJson(vfModulePayloads);
- payloadWrapper.setInnerElement(vfModulePayloadString);
- }
- }
-
- private Either<ArtifactDefinition, ResponseFormat> generateVfModuleInstanceArtifact(User modifier, ComponentInstance currVFInstance,
- Service service, boolean shouldLock, boolean inTransaction) {
- ArtifactDefinition vfModuleArtifact = null;
- Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
- Wrapper<String> payloadWrapper = new Wrapper<>();
- List<GroupInstance> groupsForCurrVF = collectGroupsInstanceForCompInstance(currVFInstance);
- if (responseWrapper.isEmpty()) {
- fillVfModuleInstHeatEnvPayload(groupsForCurrVF, payloadWrapper);
- }
- if (responseWrapper.isEmpty() && payloadWrapper.getInnerElement() != null) {
- vfModuleArtifact = getVfModuleInstArtifactForCompInstance(currVFInstance, service, payloadWrapper, responseWrapper);
- }
- if (responseWrapper.isEmpty() && vfModuleArtifact != null) {
- vfModuleArtifact = fillVfModulePayload(modifier, currVFInstance, vfModuleArtifact, shouldLock, inTransaction, payloadWrapper,
- responseWrapper, service);
- }
- Either<ArtifactDefinition, ResponseFormat> result;
- if (responseWrapper.isEmpty()) {
- result = Either.left(vfModuleArtifact);
- } else {
- result = Either.right(responseWrapper.getInnerElement());
- }
- return result;
- }
-
- private ArtifactDefinition fillVfModulePayload(User modifier, ComponentInstance currVF, ArtifactDefinition vfModuleArtifact, boolean shouldLock,
- boolean inTransaction, Wrapper<String> payloadWrapper, Wrapper<ResponseFormat> responseWrapper,
- Service service) {
- ArtifactDefinition result = null;
- Either<ArtifactDefinition, ResponseFormat> eitherPayload = artifactsBusinessLogic
- .generateArtifactPayload(vfModuleArtifact, ComponentTypeEnum.RESOURCE_INSTANCE, service, currVF.getName(), modifier, shouldLock,
- inTransaction, System::currentTimeMillis, () -> Either.left(
- artifactsBusinessLogic.createEsArtifactData(vfModuleArtifact, payloadWrapper.getInnerElement().getBytes(StandardCharsets.UTF_8))),
- currVF.getUniqueId());
- if (eitherPayload.isLeft()) {
- result = eitherPayload.left().value();
- } else {
- responseWrapper.setInnerElement(eitherPayload.right().value());
- }
- if (result == null) {
- result = vfModuleArtifact;
- }
- return result;
- }
-
- private Either<ArtifactDefinition, ResponseFormat> createVfModuleArtifact(ComponentInstance currVF, Service service,
- String vfModulePayloadString) {
- ArtifactDefinition vfModuleArtifactDefinition = new ArtifactDefinition();
- String newCheckSum = null;
- vfModuleArtifactDefinition.setDescription("Auto-generated VF Modules information artifact");
- vfModuleArtifactDefinition.setArtifactDisplayName("Vf Modules Metadata");
- vfModuleArtifactDefinition.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType());
- vfModuleArtifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- vfModuleArtifactDefinition.setArtifactLabel("vfModulesMetadata");
- vfModuleArtifactDefinition.setTimeout(0);
- vfModuleArtifactDefinition.setArtifactName(currVF.getNormalizedName() + "_modules.json");
- vfModuleArtifactDefinition.setPayloadData(vfModulePayloadString);
- if (vfModulePayloadString != null) {
- newCheckSum = GeneralUtility.calculateMD5Base64EncodedByByteArray(vfModulePayloadString.getBytes());
- }
- vfModuleArtifactDefinition.setArtifactChecksum(newCheckSum);
- Either<ArtifactDefinition, StorageOperationStatus> addArtifactToComponent = artifactToscaOperation
- .addArtifactToComponent(vfModuleArtifactDefinition, service, NodeTypeEnum.ResourceInstance, true, currVF.getUniqueId());
- Either<ArtifactDefinition, ResponseFormat> result;
- if (addArtifactToComponent.isLeft()) {
- result = Either.left(addArtifactToComponent.left().value());
- } else {
- result = Either
- .right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtifactToComponent.right().value())));
- }
- return result;
- }
-
public Either<Service, ResponseFormat> generateHeatEnvArtifacts(Service service, User modifier, boolean shouldLock, boolean inTransaction) {
Function<ComponentInstance, List<ArtifactGenerator<ArtifactDefinition>>> artifactTaskGeneratorCreator = resourceInstance ->
// Get All Deployment Artifacts
@@ -2063,7 +1943,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
log.error("Exception occured during update Group Instance property values: {}", e.getMessage(), e);
actionResult = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
} finally {
- if (lockResult != null && lockResult.isLeft() && lockResult.left().value()) {
+ if (lockResult != null && lockResult.isLeft() && Boolean.TRUE.equals(lockResult.left().value())) {
graphLockOperation.unlockComponentByName(component.getSystemName(), component.getUniqueId(), NodeTypeEnum.Service);
}
}
@@ -2249,12 +2129,12 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return latestByName.isLeft();
}
- abstract class ArtifactGenerator<CallVal> implements Callable<Either<CallVal, ResponseFormat>> {
+ interface ArtifactGenerator<CallVal> extends Callable<Either<CallVal, ResponseFormat>> {
}
@Getter
- class HeatEnvArtifactGenerator extends ArtifactGenerator<ArtifactDefinition> {
+ class HeatEnvArtifactGenerator implements ArtifactGenerator<ArtifactDefinition> {
private ArtifactDefinition artifactDefinition;
private Service service;
@@ -2283,7 +2163,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
}
- class VfModuleArtifactGenerator extends ArtifactGenerator<ArtifactDefinition> {
+ class VfModuleArtifactGenerator implements ArtifactGenerator<ArtifactDefinition> {
boolean shouldLock;
boolean inTransaction;
@@ -2301,6 +2181,126 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
this.inTransaction = inTransaction;
}
+ private Either<ArtifactDefinition, ResponseFormat> generateVfModuleInstanceArtifact(User modifier, ComponentInstance currVFInstance,
+ Service service, boolean shouldLock,
+ boolean inTransaction) {
+ ArtifactDefinition vfModuleArtifact = null;
+ Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
+ Wrapper<String> payloadWrapper = new Wrapper<>();
+ List<GroupInstance> groupsForCurrVF = collectGroupsInstanceForCompInstance(currVFInstance);
+ if (responseWrapper.isEmpty()) {
+ fillVfModuleInstHeatEnvPayload(groupsForCurrVF, payloadWrapper);
+ }
+ if (responseWrapper.isEmpty() && payloadWrapper.getInnerElement() != null) {
+ vfModuleArtifact = getVfModuleInstArtifactForCompInstance(currVFInstance, service, payloadWrapper, responseWrapper);
+ }
+ if (responseWrapper.isEmpty() && vfModuleArtifact != null) {
+ vfModuleArtifact = fillVfModulePayload(modifier, currVFInstance, vfModuleArtifact, shouldLock, inTransaction, payloadWrapper,
+ responseWrapper, service);
+ }
+ Either<ArtifactDefinition, ResponseFormat> result;
+ if (responseWrapper.isEmpty()) {
+ result = Either.left(vfModuleArtifact);
+ } else {
+ result = Either.right(responseWrapper.getInnerElement());
+ }
+ return result;
+ }
+
+ private void fillVfModuleInstHeatEnvPayload(List<GroupInstance> groupsForCurrVF, Wrapper<String> payloadWrapper) {
+ List<VfModuleArtifactPayload> vfModulePayloads = new ArrayList<>();
+ if (groupsForCurrVF != null) {
+ for (GroupInstance groupInstance : groupsForCurrVF) {
+ VfModuleArtifactPayload modulePayload = new VfModuleArtifactPayload(groupInstance);
+ vfModulePayloads.add(modulePayload);
+ }
+ vfModulePayloads.sort(VfModuleArtifactPayload::compareByGroupName);
+ final Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ String vfModulePayloadString = gson.toJson(vfModulePayloads);
+ payloadWrapper.setInnerElement(vfModulePayloadString);
+ }
+ }
+
+ private ArtifactDefinition getVfModuleInstArtifactForCompInstance(ComponentInstance currVF, Service service, Wrapper<String> payloadWrapper,
+ Wrapper<ResponseFormat> responseWrapper) {
+ ArtifactDefinition vfModuleAertifact = null;
+ if (MapUtils.isNotEmpty(currVF.getDeploymentArtifacts())) {
+ final Optional<ArtifactDefinition> optionalVfModuleArtifact = currVF.getDeploymentArtifacts().values().stream()
+ .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.getType())).findAny();
+ if (optionalVfModuleArtifact.isPresent()) {
+ vfModuleAertifact = optionalVfModuleArtifact.get();
+ }
+ }
+ if (vfModuleAertifact == null) {
+ Either<ArtifactDefinition, ResponseFormat> createVfModuleArtifact = createVfModuleArtifact(currVF, service,
+ payloadWrapper.getInnerElement());
+ if (createVfModuleArtifact.isLeft()) {
+ vfModuleAertifact = createVfModuleArtifact.left().value();
+ } else {
+ responseWrapper.setInnerElement(createVfModuleArtifact.right().value());
+ }
+ }
+ return vfModuleAertifact;
+ }
+
+ private List<GroupInstance> collectGroupsInstanceForCompInstance(ComponentInstance currVF) {
+ Map<String, ArtifactDefinition> deploymentArtifacts = currVF.getDeploymentArtifacts();
+ if (currVF.getGroupInstances() != null) {
+ currVF.getGroupInstances().forEach(gi -> gi.alignArtifactsUuid(deploymentArtifacts));
+ }
+ return currVF.getGroupInstances();
+ }
+
+ private Either<ArtifactDefinition, ResponseFormat> createVfModuleArtifact(ComponentInstance currVF, Service service,
+ String vfModulePayloadString) {
+ ArtifactDefinition vfModuleArtifactDefinition = new ArtifactDefinition();
+ String newCheckSum = null;
+ vfModuleArtifactDefinition.setDescription("Auto-generated VF Modules information artifact");
+ vfModuleArtifactDefinition.setArtifactDisplayName("Vf Modules Metadata");
+ vfModuleArtifactDefinition.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType());
+ vfModuleArtifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ vfModuleArtifactDefinition.setArtifactLabel("vfModulesMetadata");
+ vfModuleArtifactDefinition.setTimeout(0);
+ vfModuleArtifactDefinition.setArtifactName(currVF.getNormalizedName() + "_modules.json");
+ vfModuleArtifactDefinition.setPayloadData(vfModulePayloadString);
+ if (vfModulePayloadString != null) {
+ newCheckSum = GeneralUtility.calculateMD5Base64EncodedByByteArray(vfModulePayloadString.getBytes());
+ }
+ vfModuleArtifactDefinition.setArtifactChecksum(newCheckSum);
+ Either<ArtifactDefinition, StorageOperationStatus> addArtifactToComponent = artifactToscaOperation
+ .addArtifactToComponent(vfModuleArtifactDefinition, service, NodeTypeEnum.ResourceInstance, true, currVF.getUniqueId());
+ Either<ArtifactDefinition, ResponseFormat> result;
+ if (addArtifactToComponent.isLeft()) {
+ result = Either.left(addArtifactToComponent.left().value());
+ } else {
+ result = Either
+ .right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtifactToComponent.right().value())));
+ }
+ return result;
+ }
+
+ private ArtifactDefinition fillVfModulePayload(User modifier, ComponentInstance currVF, ArtifactDefinition vfModuleArtifact,
+ boolean shouldLock,
+ boolean inTransaction, Wrapper<String> payloadWrapper, Wrapper<ResponseFormat> responseWrapper,
+ Service service) {
+ ArtifactDefinition result = null;
+ Either<ArtifactDefinition, ResponseFormat> eitherPayload = artifactsBusinessLogic
+ .generateArtifactPayload(vfModuleArtifact, ComponentTypeEnum.RESOURCE_INSTANCE, service, currVF.getName(), modifier, shouldLock,
+ inTransaction, System::currentTimeMillis, () -> Either.left(
+ artifactsBusinessLogic.createEsArtifactData(vfModuleArtifact,
+ payloadWrapper.getInnerElement().getBytes(StandardCharsets.UTF_8))),
+ currVF.getUniqueId());
+ if (eitherPayload.isLeft()) {
+ result = eitherPayload.left().value();
+ } else {
+ responseWrapper.setInnerElement(eitherPayload.right().value());
+ }
+ if (result == null) {
+ result = vfModuleArtifact;
+ }
+ return result;
+ }
+
@Override
public Either<ArtifactDefinition, ResponseFormat> call() throws Exception {
return generateVfModuleInstanceArtifact(user, componentInstance, service, shouldLock, inTransaction);
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 dd55ae8612..34460f46d5 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
@@ -67,6 +67,7 @@ import org.openecomp.sdc.be.components.validation.component.ComponentValidator;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
@@ -97,6 +98,7 @@ 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.ParsedToscaYamlInfo;
+import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RelationshipImpl;
import org.openecomp.sdc.be.model.RelationshipInfo;
@@ -119,6 +121,7 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
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;
@@ -135,7 +138,6 @@ import org.openecomp.sdc.common.kpi.api.ASDCKpiApi;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
-import org.springframework.beans.factory.annotation.Autowired;
import org.yaml.snakeyaml.Yaml;
@Getter
@@ -143,9 +145,9 @@ import org.yaml.snakeyaml.Yaml;
@org.springframework.stereotype.Component("serviceImportBusinessLogic")
public class ServiceImportBusinessLogic {
+ protected static final String CREATE_RESOURCE = "Create Resource";
private static final String INITIAL_VERSION = "0.1";
- private static final String CREATE_RESOURCE = "Create Resource";
- private static final String IN_RESOURCE = " in resource {} ";
+ private static final String IN_RESOURCE = " in resource {} ";
private static final String COMPONENT_INSTANCE_WITH_NAME = "component instance with name ";
private static final String COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE = "component instance with name {} in resource {} ";
private static final String CERTIFICATION_ON_IMPORT = "certification on import";
@@ -154,30 +156,25 @@ public class ServiceImportBusinessLogic {
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(ServiceImportBusinessLogic.class);
+
+ private final ComponentsUtils componentsUtils;
+ private final ToscaOperationFacade toscaOperationFacade;
private final UiComponentDataConverter uiComponentDataConverter;
private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
- @Autowired
- protected ComponentsUtils componentsUtils;
- @Autowired
- protected ToscaOperationFacade toscaOperationFacade;
- @Autowired
- private ServiceBusinessLogic serviceBusinessLogic;
- @Autowired
- private CsarBusinessLogic csarBusinessLogic;
- @Autowired
- private CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic;
- @Autowired
- private LifecycleBusinessLogic lifecycleBusinessLogic;
- @Autowired
- private CompositionBusinessLogic compositionBusinessLogic;
- @Autowired
- private ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic;
- @Autowired
- private ServiceImportParseLogic serviceImportParseLogic;
- @Autowired
- private ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
-
- @Autowired
+ private final ServiceBusinessLogic serviceBusinessLogic;
+ private final CsarBusinessLogic csarBusinessLogic;
+ private final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic;
+ private final LifecycleBusinessLogic lifecycleBusinessLogic;
+ private final CompositionBusinessLogic compositionBusinessLogic;
+ private final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic;
+ private final ServiceImportParseLogic serviceImportParseLogic;
+ private final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
+ private final GroupBusinessLogic groupBusinessLogic;
+ private final PolicyBusinessLogic policyBusinessLogic;
+ private final JanusGraphDao janusGraphDao;
+ private final ArtifactsBusinessLogic artifactsBusinessLogic;
+ private final IGraphLockOperation graphLockOperation;
+
public ServiceImportBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, IGroupInstanceOperation groupInstanceOperation,
IGroupTypeOperation groupTypeOperation, GroupBusinessLogic groupBusinessLogic,
InterfaceOperation interfaceOperation, InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
@@ -189,17 +186,33 @@ public class ServiceImportBusinessLogic {
ComponentContactIdValidator componentContactIdValidator, ComponentNameValidator componentNameValidator,
ComponentTagsValidator componentTagsValidator, ComponentValidator componentValidator,
ComponentIconValidator componentIconValidator, ComponentProjectCodeValidator componentProjectCodeValidator,
- ComponentDescriptionValidator componentDescriptionValidator) {
+ ComponentDescriptionValidator componentDescriptionValidator, final ComponentsUtils componentsUtils,
+ final ToscaOperationFacade toscaOperationFacade, final ServiceBusinessLogic serviceBusinessLogic,
+ final CsarBusinessLogic csarBusinessLogic,
+ final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic,
+ final LifecycleBusinessLogic lifecycleBusinessLogic, final CompositionBusinessLogic compositionBusinessLogic,
+ final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic,
+ final ServiceImportParseLogic serviceImportParseLogic,
+ final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic,
+ final PolicyBusinessLogic policyBusinessLogic, final JanusGraphDao janusGraphDao,
+ final IGraphLockOperation graphLockOperation) {
this.componentInstanceBusinessLogic = componentInstanceBusinessLogic;
this.uiComponentDataConverter = uiComponentDataConverter;
- }
-
- public ServiceBusinessLogic getServiceBusinessLogic() {
- return serviceBusinessLogic;
- }
-
- public void setServiceBusinessLogic(ServiceBusinessLogic serviceBusinessLogic) {
+ this.componentsUtils = componentsUtils;
+ this.toscaOperationFacade = toscaOperationFacade;
this.serviceBusinessLogic = serviceBusinessLogic;
+ this.csarBusinessLogic = csarBusinessLogic;
+ this.csarArtifactsAndGroupsBusinessLogic = csarArtifactsAndGroupsBusinessLogic;
+ this.lifecycleBusinessLogic = lifecycleBusinessLogic;
+ this.compositionBusinessLogic = compositionBusinessLogic;
+ this.resourceDataMergeBusinessLogic = resourceDataMergeBusinessLogic;
+ this.serviceImportParseLogic = serviceImportParseLogic;
+ this.componentNodeFilterBusinessLogic = componentNodeFilterBusinessLogic;
+ this.groupBusinessLogic = groupBusinessLogic;
+ this.policyBusinessLogic = policyBusinessLogic;
+ this.janusGraphDao = janusGraphDao;
+ this.artifactsBusinessLogic = artifactsBusinessLogic;
+ this.graphLockOperation = graphLockOperation;
}
public Service createService(Service service, AuditingActionEnum auditingAction, User user, Map<String, byte[]> csarUIPayload,
@@ -211,7 +224,10 @@ public class ServiceImportBusinessLogic {
service.setConformanceLevel(ConfigurationManager.getConfigurationManager().getConfiguration().getToscaConformanceLevel());
service.setDistributionStatus(DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED);
try {
- serviceBusinessLogic.validateServiceBeforeCreate(service, user, auditingAction);
+ final var serviceBeforeCreate = serviceBusinessLogic.validateServiceBeforeCreate(service, user, auditingAction);
+ if (serviceBeforeCreate.isRight()) {
+ throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ }
log.debug("enter createService,validateServiceBeforeCreate success");
String csarUUID = payloadName == null ? service.getCsarUUID() : payloadName;
log.debug("enter createService,get csarUUID:{}", csarUUID);
@@ -318,8 +334,8 @@ 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);
- Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = serviceBusinessLogic.groupBusinessLogic
- .validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), service.getSystemName());
+ Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes
+ = groupBusinessLogic.validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), service.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
serviceImportParseLogic.rollback(inTransaction, service, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
@@ -337,6 +353,13 @@ public class ServiceImportBusinessLogic {
throw new ComponentException(createGroupsOnResource.right().value());
}
service = createGroupsOnResource.left().value();
+
+ Either<Service, ResponseFormat> createPoliciesOnResource = createPoliciesOnResource(service, parsedToscaYamlInfo.getPolicies());
+ if (createPoliciesOnResource.isRight()) {
+ serviceImportParseLogic.rollback(inTransaction, service, createdArtifacts, nodeTypesNewCreatedArtifacts);
+ throw new ComponentException(createPoliciesOnResource.right().value());
+ }
+ service = createPoliciesOnResource.left().value();
log.trace("************* Going to add artifacts from yaml {}", yamlName);
NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName, nodeTypesArtifactsToCreate);
Either<Service, ResponseFormat> createArtifactsEither = createOrUpdateArtifacts(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE,
@@ -353,10 +376,10 @@ public class ServiceImportBusinessLogic {
throw e;
} finally {
if (!inTransaction) {
- serviceBusinessLogic.janusGraphDao.commit();
+ janusGraphDao.commit();
}
if (shouldLock) {
- serviceBusinessLogic.graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(), NodeTypeEnum.Resource);
+ graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(), NodeTypeEnum.Resource);
}
}
}
@@ -445,11 +468,11 @@ public class ServiceImportBusinessLogic {
Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId, artifactOperation, null, true, shouldLock, inTransaction);
}
- protected Either<Resource, ResponseFormat> getResourceResponseFormatEither(Resource resource, CsarInfo csarInfo,
- List<ArtifactDefinition> createdArtifacts,
- ArtifactOperationInfo artifactOperation, boolean shouldLock,
- boolean inTransaction,
- Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus) {
+ private Either<Resource, ResponseFormat> getResourceResponseFormatEither(Resource resource, CsarInfo csarInfo,
+ List<ArtifactDefinition> createdArtifacts,
+ ArtifactOperationInfo artifactOperation, boolean shouldLock,
+ boolean inTransaction,
+ Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus) {
try {
String artifactsFileName = artifacsMetaCsarStatus.left().value().getKey();
String artifactsContents = artifacsMetaCsarStatus.left().value().getValue();
@@ -561,7 +584,7 @@ public class ServiceImportBusinessLogic {
if (operation.getArtifactOperationEnum() == ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE
|| operation.getArtifactOperationEnum() == ArtifactsBusinessLogic.ArtifactOperationEnum.DELETE) {
if (serviceImportParseLogic.isArtifactDeletionRequired(artifactId, artifactFileBytes, isFromCsar)) {
- Either<ArtifactDefinition, ResponseFormat> handleDelete = serviceBusinessLogic.artifactsBusinessLogic
+ Either<ArtifactDefinition, ResponseFormat> handleDelete = artifactsBusinessLogic
.handleDelete(component.getUniqueId(), artifactId, csarInfo.getModifier(), component, shouldLock, inTransaction);
if (handleDelete.isRight()) {
result = Either.right(handleDelete.right().value());
@@ -589,10 +612,10 @@ public class ServiceImportBusinessLogic {
return result;
}
- public Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifacts(Resource nodeTypeResource,
- Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
- List<ArtifactDefinition> createdArtifacts, User user,
- boolean inTransaction, boolean ignoreLifecycleState) {
+ private Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifacts(Resource nodeTypeResource,
+ Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
+ List<ArtifactDefinition> createdArtifacts, User user,
+ boolean inTransaction, boolean ignoreLifecycleState) {
List<ArtifactDefinition> handleNodeTypeArtifactsRequestRes;
Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes = null;
Either<Resource, ResponseFormat> changeStateResponse;
@@ -610,7 +633,7 @@ public class ServiceImportBusinessLogic {
List<ArtifactDefinition> curArtifactsToHandle = curOperationEntry.getValue();
if (curArtifactsToHandle != null && !curArtifactsToHandle.isEmpty()) {
log.debug("************* Going to {} artifact to vfc {}", curOperation.name(), nodeTypeResource.getName());
- handleNodeTypeArtifactsRequestRes = serviceBusinessLogic.artifactsBusinessLogic
+ handleNodeTypeArtifactsRequestRes = artifactsBusinessLogic
.handleArtifactsRequestForInnerVfcComponent(curArtifactsToHandle, nodeTypeResource, user, createdArtifacts,
new ArtifactOperationInfo(false, ignoreLifecycleState, curOperation), false, inTransaction);
if (ArtifactsBusinessLogic.ArtifactOperationEnum.isCreateOrLink(curOperation)) {
@@ -630,7 +653,7 @@ public class ServiceImportBusinessLogic {
return handleNodeTypeArtifactsRes;
}
- protected Either<Resource, ResponseFormat> checkoutResource(Resource resource, User user, boolean inTransaction) {
+ private Either<Resource, ResponseFormat> checkoutResource(Resource resource, User user, boolean inTransaction) {
Either<Resource, ResponseFormat> checkoutResourceRes;
try {
if (!resource.getComponentMetadataDefinition().getMetadataDataDefinition().getState()
@@ -768,7 +791,7 @@ public class ServiceImportBusinessLogic {
return organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifacts, component, user);
}
- protected boolean isNonMetaArtifact(ArtifactDefinition artifact) {
+ private boolean isNonMetaArtifact(ArtifactDefinition artifact) {
boolean result = true;
if (artifact.getMandatory() || artifact.getArtifactName() == null || !isValidArtifactType(artifact)) {
result = false;
@@ -777,12 +800,10 @@ public class ServiceImportBusinessLogic {
}
private boolean isValidArtifactType(ArtifactDefinition artifact) {
- boolean result = true;
- if (artifact.getArtifactType() == null || ArtifactTypeEnum.findType(artifact.getArtifactType()).equals(ArtifactTypeEnum.VENDOR_LICENSE)
- || ArtifactTypeEnum.findType(artifact.getArtifactType()).equals(ArtifactTypeEnum.VF_LICENSE)) {
- result = false;
- }
- return result;
+ final String artifactType = artifact.getArtifactType();
+ return artifactType != null
+ && !ArtifactTypeEnum.VENDOR_LICENSE.getType().equals(ArtifactTypeEnum.findType(artifactType))
+ && !ArtifactTypeEnum.VF_LICENSE.getType().equals(ArtifactTypeEnum.findType(artifactType));
}
protected Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> organizeVfCsarArtifactsByArtifactOperation(
@@ -815,12 +836,11 @@ public class ServiceImportBusinessLogic {
ResponseFormat responseFormat = ResponseFormatManager.getInstance()
.getResponseFormat(ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, currNewArtifact.getArtifactName(),
currNewArtifact.getArtifactType(), foundArtifact.getArtifactType());
- AuditingActionEnum auditingAction = serviceBusinessLogic.artifactsBusinessLogic
- .detectAuditingType(new ArtifactOperationInfo(false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE),
- foundArtifact.getArtifactChecksum());
- serviceBusinessLogic.artifactsBusinessLogic
- .handleAuditing(auditingAction, component, component.getUniqueId(), user, null, null, foundArtifact.getUniqueId(),
- responseFormat, component.getComponentType(), null);
+ AuditingActionEnum auditingAction = artifactsBusinessLogic.detectAuditingType(
+ new ArtifactOperationInfo(false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE),
+ foundArtifact.getArtifactChecksum());
+ artifactsBusinessLogic.handleAuditing(auditingAction, component, component.getUniqueId(), user, null, null,
+ foundArtifact.getUniqueId(), responseFormat, component.getComponentType(), null);
responseWrapper.setInnerElement(responseFormat);
break;
}
@@ -863,14 +883,6 @@ public class ServiceImportBusinessLogic {
return nodeTypeArtifactsToHandleRes;
}
- public ComponentsUtils getComponentsUtils() {
- return this.componentsUtils;
- }
-
- public void setComponentsUtils(ComponentsUtils componentsUtils) {
- this.componentsUtils = componentsUtils;
- }
-
protected Either<List<CsarUtils.NonMetaArtifactInfo>, String> getValidArtifactNames(CsarInfo csarInfo,
Map<String, Set<List<String>>> collectedWarningMessages) {
List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = csarInfo.getCsar().entrySet().stream()
@@ -891,14 +903,27 @@ public class ServiceImportBusinessLogic {
List<GroupDefinition> groupsAsList = updateGroupsMembersUsingResource(groups, service);
serviceImportParseLogic.handleGroupsProperties(service, groups);
serviceImportParseLogic.fillGroupsFinalFields(groupsAsList);
- Either<List<GroupDefinition>, ResponseFormat> createGroups = serviceBusinessLogic.groupBusinessLogic
- .createGroups(service, groupsAsList, true);
+ Either<List<GroupDefinition>, ResponseFormat> createGroups = groupBusinessLogic.createGroups(service, groupsAsList, true);
if (createGroups.isRight()) {
return Either.right(createGroups.right().value());
}
} else {
return Either.left(service);
}
+ return getServiceResponseFormatEither(service);
+ }
+
+ private Either<Service, ResponseFormat> createPoliciesOnResource(Service service,
+ Map<String, PolicyDefinition> policies) {
+ if (MapUtils.isNotEmpty(policies)) {
+ policyBusinessLogic.createPolicies(service, policies);
+ } else {
+ return Either.left(service);
+ }
+ return getServiceResponseFormatEither(service);
+ }
+
+ private Either<Service, ResponseFormat> getServiceResponseFormatEither(Service service) {
Either<Service, StorageOperationStatus> updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId());
if (updatedResource.isRight()) {
ResponseFormat responseFormat = componentsUtils
@@ -1232,11 +1257,11 @@ public class ServiceImportBusinessLogic {
return result;
}
- public Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Resource resource, Map<String, Object> mappedToscaTemplate,
- boolean needLock,
- Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
- Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo) {
+ private Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Resource resource, Map<String, Object> mappedToscaTemplate,
+ boolean needLock,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo) {
Either<String, ImportUtils.ResultStatusEnum> toscaVersion = findFirstToscaStringElement(mappedToscaTemplate,
TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
if (toscaVersion.isRight()) {
@@ -1304,7 +1329,7 @@ public class ServiceImportBusinessLogic {
log.debug("************* Going to create all nodes {}", yamlName);
handleServiceNodeTypes(yamlName, service, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts,
nodeTypesInfo, csarInfo, nodeName);
- if (!MapUtils.isEmpty(uploadComponentInstanceInfoMap)) {
+ if (MapUtils.isNotEmpty(uploadComponentInstanceInfoMap)) {
log.debug("************* Going to create all resource instances {}", yamlName);
service = createServiceInstances(yamlName, service, uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
log.debug("************* Going to create all relations {}", yamlName);
@@ -1364,7 +1389,6 @@ public class ServiceImportBusinessLogic {
service = getResourceAfterCreateRelations(service);
addRelationsToRI(yamlName, service, uploadResInstancesMap, componentInstancesList, relations);
serviceImportParseLogic.associateResourceInstances(yamlName, service, relations);
- handleSubstitutionMappings(service, uploadResInstancesMap);
log.debug("************* in create relations, getResource start");
Either<Service, StorageOperationStatus> eitherGetResource = toscaOperationFacade.getToscaElement(service.getUniqueId());
log.debug("************* in create relations, getResource end");
@@ -1574,7 +1598,7 @@ public class ServiceImportBusinessLogic {
originResource.getCapabilities().forEach((k, v) -> serviceImportParseLogic.addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values()
.forEach(l -> serviceImportParseLogic.addCapabilitiesProperties(newPropertiesMap, l));
- updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap, originResource.getModel());
+ updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
} else {
originCapabilities = originResource.getCapabilities();
}
@@ -1583,7 +1607,7 @@ public class ServiceImportBusinessLogic {
protected void updateCapabilityPropertiesValues(Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, Map<String, UploadPropInfo>> newPropertiesMap, String model) {
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
originCapabilities.values().stream().flatMap(Collection::stream).filter(c -> newPropertiesMap.containsKey(c.getName()))
.forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes));
}
@@ -1630,25 +1654,6 @@ public class ServiceImportBusinessLogic {
return originResource;
}
- protected void handleSubstitutionMappings(Service service, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
- if (false) {
- Either<Resource, StorageOperationStatus> getResourceRes = toscaOperationFacade.getToscaFullElement(service.getUniqueId());
- if (getResourceRes.isRight()) {
- ResponseFormat responseFormat = componentsUtils
- .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), service,
- ComponentTypeEnum.SERVICE);
- throw new ComponentException(responseFormat);
- }
- getResourceRes = updateCalculatedCapReqWithSubstitutionMappings(getResourceRes.left().value(), uploadResInstancesMap);
- if (getResourceRes.isRight()) {
- ResponseFormat responseFormat = componentsUtils
- .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), service,
- ComponentTypeEnum.SERVICE);
- throw new ComponentException(responseFormat);
- }
- }
- }
-
protected Either<Resource, StorageOperationStatus> updateCalculatedCapReqWithSubstitutionMappings(Resource resource,
Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
Either<Resource, StorageOperationStatus> updateRes = null;
@@ -1818,15 +1823,15 @@ public class ServiceImportBusinessLogic {
log.debug("try to find aviable Capability req name is {} ", validReq.getName());
CapabilityDefinition aviableCapForRel = serviceImportParseLogic
.findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadRegInfo);
- reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
- reqAndRelationshipPair.setCapabilityUid(aviableCapForRel.getUniqueId());
- reqAndRelationshipPair.setCapabilityOwnerId(aviableCapForRel.getOwnerId());
if (aviableCapForRel == null) {
BeEcompErrorManager.getInstance().logInternalDataError(
"aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance
.getUniqueId(), service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
+ reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
+ reqAndRelationshipPair.setCapabilityUid(aviableCapForRel.getUniqueId());
+ reqAndRelationshipPair.setCapabilityOwnerId(aviableCapForRel.getOwnerId());
CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
capReqRel.setRelation(reqAndRelationshipPair);
reqAndRelationshipPairList.add(capReqRel);
@@ -2144,8 +2149,8 @@ public class ServiceImportBusinessLogic {
.auditResource(responseFormat, csarInfo.getModifier(), preparedResource == null ? oldRresource : preparedResource, actionEnum);
throw e;
}
- Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = serviceBusinessLogic.groupBusinessLogic
- .validateUpdateVfGroupNames(uploadComponentInstanceInfoMap.getGroups(), preparedResource.getSystemName());
+ Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = groupBusinessLogic.validateUpdateVfGroupNames(
+ uploadComponentInstanceInfoMap.getGroups(), preparedResource.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
}
@@ -2237,8 +2242,8 @@ public class ServiceImportBusinessLogic {
nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName);
log.trace("************* Finished to create nodes, RI and Relation from yaml {}", yamlName);
// validate update vf module group names
- Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = serviceBusinessLogic.groupBusinessLogic
- .validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), resource.getSystemName());
+ Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = groupBusinessLogic.validateUpdateVfGroupNames(
+ parsedToscaYamlInfo.getGroups(), resource.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
serviceImportParseLogic.rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
@@ -2274,11 +2279,10 @@ public class ServiceImportBusinessLogic {
throw e;
} finally {
if (!inTransaction) {
- serviceBusinessLogic.janusGraphDao.commit();
+ janusGraphDao.commit();
}
if (shouldLock) {
- serviceBusinessLogic.graphLockOperation
- .unlockComponentByName(resource.getSystemName(), resource.getUniqueId(), NodeTypeEnum.Resource);
+ graphLockOperation.unlockComponentByName(resource.getSystemName(), resource.getUniqueId(), NodeTypeEnum.Resource);
}
}
}
@@ -2288,8 +2292,7 @@ public class ServiceImportBusinessLogic {
List<GroupDefinition> groupsAsList = updateGroupsMembersUsingResource(groups, resource);
serviceImportParseLogic.handleGroupsProperties(resource, groups);
serviceImportParseLogic.fillGroupsFinalFields(groupsAsList);
- Either<List<GroupDefinition>, ResponseFormat> createGroups = serviceBusinessLogic.groupBusinessLogic
- .createGroups(resource, groupsAsList, true);
+ Either<List<GroupDefinition>, ResponseFormat> createGroups = groupBusinessLogic.createGroups(resource, groupsAsList, true);
if (createGroups.isRight()) {
return Either.right(createGroups.right().value());
}
@@ -2407,13 +2410,13 @@ public class ServiceImportBusinessLogic {
} finally {
if (resourcePair == null) {
BeEcompErrorManager.getInstance().logBeSystemError("Change LifecycleState - Certify");
- serviceBusinessLogic.janusGraphDao.rollback();
+ janusGraphDao.rollback();
} else if (!inTransaction) {
- serviceBusinessLogic.janusGraphDao.commit();
+ janusGraphDao.commit();
}
if (needLock) {
log.debug("unlock resource {}", lockedResourceId);
- serviceBusinessLogic.graphLockOperation.unlockComponent(lockedResourceId, NodeTypeEnum.Resource);
+ graphLockOperation.unlockComponent(lockedResourceId, NodeTypeEnum.Resource);
}
}
}
@@ -2491,23 +2494,24 @@ public class ServiceImportBusinessLogic {
Resource vfcCreated = null;
while (nodesNameValueIter.hasNext()) {
Map.Entry<String, Object> nodeType = nodesNameValueIter.next();
+ String nodeTypeKey = nodeType.getKey();
Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle =
- nodeTypesArtifactsToHandle == null || nodeTypesArtifactsToHandle.isEmpty() ? null : nodeTypesArtifactsToHandle.get(nodeType.getKey());
- if (nodeTypesInfo.containsKey(nodeType.getKey())) {
+ nodeTypesArtifactsToHandle == null || nodeTypesArtifactsToHandle.isEmpty() ? null : nodeTypesArtifactsToHandle.get(nodeTypeKey);
+ if (nodeTypesInfo.containsKey(nodeTypeKey)) {
vfcCreated = handleNestedVfc(service, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
- nodeType.getKey());
- log.trace("************* Finished to handle nested vfc {}", nodeType.getKey());
+ nodeTypeKey);
+ log.trace("************* Finished to handle nested vfc {}", nodeTypeKey);
} else if (csarInfo.getCreatedNodesToscaResourceNames() != null && !csarInfo.getCreatedNodesToscaResourceNames()
- .containsKey(nodeType.getKey())) {
+ .containsKey(nodeTypeKey)) {
ImmutablePair<Resource, ActionStatus> resourceCreated = serviceImportParseLogic
.createNodeTypeResourceFromYaml(yamlName, nodeType, csarInfo.getModifier(), mapToConvert, service, needLock,
nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, true, csarInfo, true);
- log.debug("************* Finished to create node {}", nodeType.getKey());
+ log.debug("************* Finished to create node {}", nodeTypeKey);
vfcCreated = resourceCreated.getLeft();
- csarInfo.getCreatedNodesToscaResourceNames().put(nodeType.getKey(), vfcCreated.getName());
+ csarInfo.getCreatedNodesToscaResourceNames().put(nodeTypeKey, vfcCreated.getName());
}
if (vfcCreated != null) {
- csarInfo.getCreatedNodes().put(nodeType.getKey(), vfcCreated);
+ csarInfo.getCreatedNodes().put(nodeTypeKey, vfcCreated);
}
mapToConvert.remove(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName());
}
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 63abf26ef4..7a5b90976f 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
@@ -32,7 +32,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import lombok.Getter;
-import lombok.Setter;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@@ -118,7 +117,6 @@ import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
@Getter
-@Setter
@org.springframework.stereotype.Component
public class ServiceImportParseLogic {
@@ -134,25 +132,46 @@ public class ServiceImportParseLogic {
private static final String CATEGORY_IS_EMPTY = "Resource category is empty";
private static final Logger log = Logger.getLogger(ServiceImportParseLogic.class);
@Autowired
- private ServiceBusinessLogic serviceBusinessLogic;
+ private final ServiceBusinessLogic serviceBusinessLogic;
@Autowired
- private ComponentsUtils componentsUtils;
+ private final ComponentsUtils componentsUtils;
@Autowired
- private ToscaOperationFacade toscaOperationFacade;
+ private final ToscaOperationFacade toscaOperationFacade;
@Autowired
- private LifecycleBusinessLogic lifecycleBusinessLogic;
+ private final LifecycleBusinessLogic lifecycleBusinessLogic;
@Autowired
- private InputsBusinessLogic inputsBusinessLogic;
+ private final InputsBusinessLogic inputsBusinessLogic;
@Autowired
- private ResourceImportManager resourceImportManager;
+ private final ResourceImportManager resourceImportManager;
@Autowired
- private ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic;
+ private final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic;
@Autowired
- private IInterfaceLifecycleOperation interfaceTypeOperation = null;
+ private final IInterfaceLifecycleOperation interfaceTypeOperation;
@Autowired
- private ICapabilityTypeOperation capabilityTypeOperation = null;
+ private final ICapabilityTypeOperation capabilityTypeOperation;
@Autowired
- private ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
+ private final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
+ private final GroupBusinessLogic groupBusinessLogic;
+
+ public ServiceImportParseLogic(final ServiceBusinessLogic serviceBusinessLogic, final ComponentsUtils componentsUtils,
+ final ToscaOperationFacade toscaOperationFacade, final LifecycleBusinessLogic lifecycleBusinessLogic,
+ final InputsBusinessLogic inputsBusinessLogic, final ResourceImportManager resourceImportManager,
+ final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic,
+ final IInterfaceLifecycleOperation interfaceTypeOperation, final ICapabilityTypeOperation capabilityTypeOperation,
+ final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic,
+ final GroupBusinessLogic groupBusinessLogic) {
+ this.serviceBusinessLogic = serviceBusinessLogic;
+ this.componentsUtils = componentsUtils;
+ this.toscaOperationFacade = toscaOperationFacade;
+ this.lifecycleBusinessLogic = lifecycleBusinessLogic;
+ this.inputsBusinessLogic = inputsBusinessLogic;
+ this.resourceImportManager = resourceImportManager;
+ this.substitutionFilterBusinessLogic = substitutionFilterBusinessLogic;
+ this.interfaceTypeOperation = interfaceTypeOperation;
+ this.capabilityTypeOperation = capabilityTypeOperation;
+ this.componentNodeFilterBusinessLogic = componentNodeFilterBusinessLogic;
+ this.groupBusinessLogic = groupBusinessLogic;
+ }
public Either<Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(
Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, Service oldResource) {
@@ -1634,18 +1653,16 @@ public class ServiceImportParseLogic {
if (isNotEmpty(groupsToCreate)) {
fillGroupsFinalFields(groupsToCreate);
if (isNotEmpty(groupsFromResource)) {
- serviceBusinessLogic.groupBusinessLogic.addGroups(resource, groupsToCreate, true).left()
- .on(serviceBusinessLogic::throwComponentException);
+ groupBusinessLogic.addGroups(resource, groupsToCreate, true).left().on(serviceBusinessLogic::throwComponentException);
} else {
- serviceBusinessLogic.groupBusinessLogic.createGroups(resource, groupsToCreate, true).left()
- .on(serviceBusinessLogic::throwComponentException);
+ groupBusinessLogic.createGroups(resource, groupsToCreate, true).left().on(serviceBusinessLogic::throwComponentException);
}
}
if (isNotEmpty(groupsToDelete)) {
- serviceBusinessLogic.groupBusinessLogic.deleteGroups(resource, groupsToDelete).left().on(serviceBusinessLogic::throwComponentException);
+ groupBusinessLogic.deleteGroups(resource, groupsToDelete).left().on(serviceBusinessLogic::throwComponentException);
}
if (isNotEmpty(groupsToUpdate)) {
- serviceBusinessLogic.groupBusinessLogic.updateGroups(resource, groupsToUpdate, true).left()
+ groupBusinessLogic.updateGroups(resource, groupsToUpdate, true).left()
.on(serviceBusinessLogic::throwComponentException);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/PolicyServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/PolicyServlet.java
index a7bd4b62b2..8ba84b80a5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/PolicyServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/PolicyServlet.java
@@ -28,9 +28,7 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.servers.Server;
-import io.swagger.v3.oas.annotations.servers.Servers;
import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.tags.Tags;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -81,8 +79,8 @@ import org.springframework.stereotype.Controller;
*/
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Tags({@Tag(name = "SDCE-2 APIs")})
-@Servers({@Server(url = "/sdc2/rest")})
+@Tag(name = "SDCE-2 APIs")
+@Server(url = "/sdc2/rest")
@Controller
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
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 bcedc60d40..c26f3ca522 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
@@ -19,6 +19,8 @@
*/
package org.openecomp.sdc.be.servlets;
+import static org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.reflect.TypeToken;
@@ -31,9 +33,7 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.servers.Server;
-import io.swagger.v3.oas.annotations.servers.Servers;
import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.tags.Tags;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -52,8 +52,8 @@ import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -99,7 +99,7 @@ import org.springframework.stereotype.Controller;
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Servers({@Server(url = "/sdc2/rest")})
+@Server(url = "/sdc2/rest")
@Controller
public class ServiceServlet extends AbstractValidationsServlet {
@@ -110,8 +110,6 @@ public class ServiceServlet extends AbstractValidationsServlet {
private final ElementBusinessLogic elementBusinessLogic;
private final ServiceBusinessLogic serviceBusinessLogic;
- public enum Action {DELETE, MARK_AS_DELETE}
-
@Inject
public ServiceServlet(UserBusinessLogic userBusinessLogic, ComponentInstanceBusinessLogic componentInstanceBL, ComponentsUtils componentsUtils,
ServletUtils servletUtils, ResourceImportManager resourceImportManager, ServiceBusinessLogic serviceBusinessLogic,
@@ -123,7 +121,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@POST
@Path("/services")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Create Service", method = "POST", summary = "Returns created service", responses = {
@@ -136,8 +134,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
loggerSupportability.log(LoggerSupportabilityActions.CREATE_SERVICE, StatusCode.STARTED, "Starting to create a service by user {} ", userId);
validateNotEmptyBody(data);
@@ -163,7 +160,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@GET
@Path("/services/validate-name/{serviceName}")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "validate service name", method = "GET", summary = "checks if the chosen service name is available ", responses = {
@@ -174,9 +171,6 @@ public class ServiceServlet extends AbstractValidationsServlet {
@HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- // get modifier id
- User modifier = new User();
- modifier.setUserId(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
Either<Map<String, Boolean>, ResponseFormat> actionResponse = serviceBusinessLogic.validateServiceNameExists(serviceName, userId);
@@ -194,7 +188,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@GET
@Path("/audit-records/{componentType}/{componentUniqueId}")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "get component audit records", method = "GET", summary = "get audit records for a service or a resource", responses = {
@@ -209,8 +203,6 @@ public class ServiceServlet extends AbstractValidationsServlet {
ServletContext context = request.getSession().getServletContext();
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- User modifier = new User();
- modifier.setUserId(userId);
log.debug(MODIFIER_ID_IS, userId);
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<String> uuidWrapper = new Wrapper<>();
@@ -265,7 +257,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@DELETE
@Path("/services/{serviceId}")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Operation(description = "Delete Service", method = "DELETE", summary = "Return no content", responses = {
@ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Service.class)))),
@ApiResponse(responseCode = "204", description = "Service deleted"), @ApiResponse(responseCode = "403", description = "Restricted operation"),
@@ -274,8 +266,8 @@ public class ServiceServlet extends AbstractValidationsServlet {
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response deleteService(@PathParam("serviceId") final String serviceId,
@Parameter(description = "Optional parameter to determine the delete action: " +
- "DELETE, which will permanently delete theService from the system or " +
- "MARK_AS_DELETE, which will logically mark the service as deleted. Default action is to MARK_AS_DELETE")
+ "DELETE, which will permanently delete theService from the system or " +
+ "MARK_AS_DELETE, which will logically mark the service as deleted. Default action is to MARK_AS_DELETE")
@QueryParam("deleteAction") final Action deleteAction,
@Context final HttpServletRequest request) {
ServletContext context = request.getSession().getServletContext();
@@ -283,8 +275,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
log.debug(START_HANDLE_REQUEST_OF, url);
// get modifier id
String userId = request.getHeader(Constants.USER_ID_HEADER);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
String serviceIdLower = serviceId.toLowerCase();
@@ -315,7 +306,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@DELETE
@Path("/services/{serviceName}/{version}")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Operation(description = "Delete Service By Name And Version", method = "DELETE", summary = "Returns no content", responses = {
@ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))),
@ApiResponse(responseCode = "204", description = "Service deleted"), @ApiResponse(responseCode = "403", description = "Restricted operation"),
@@ -344,15 +335,14 @@ public class ServiceServlet extends AbstractValidationsServlet {
log.debug(START_HANDLE_REQUEST_OF, url);
// get modifier id
String userId = request.getHeader(Constants.USER_ID_HEADER);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
return modifier;
}
@PUT
@Path("/services/{serviceId}/metadata")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Update Service Metadata", method = "PUT", summary = "Returns updated service", responses = {
@@ -366,8 +356,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
throws IOException {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
String serviceIdLower = serviceId.toLowerCase();
@@ -406,7 +395,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
*/
@PUT
@Path("/{containerComponentType}/{serviceId}/resourceInstance/{componentInstanceId}/groupInstance/{groupInstanceId}")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Update Group Instance Property Values", method = "PUT", summary = "Returns updated group instance", responses = {
@@ -423,8 +412,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@HeaderParam(value = Constants.USER_ID_HEADER) String userId) throws JsonProcessingException {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
Either<List<GroupInstanceProperty>, ResponseFormat> actionResponse = null;
try {
@@ -452,14 +440,14 @@ public class ServiceServlet extends AbstractValidationsServlet {
return buildErrorResponse(actionResponse.right().value());
}
} catch (Exception e) {
- log.error("Exception occured during update Group Instance property values: {}", e.getMessage(), e);
+ log.error(BUSINESS_PROCESS_ERROR, this.getClass().getName(), "Exception occured during update Group Instance property values.", e);
throw e;
}
}
@GET
@Path("/services/{serviceId}")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Retrieve Service", method = "GET", summary = "Returns service according to serviceId", responses = {
@@ -472,8 +460,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
// get modifier id
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
String serviceIdLower = serviceId.toLowerCase();
@@ -495,7 +482,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@GET
@Path("/services/serviceName/{serviceName}/serviceVersion/{serviceVersion}")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Retrieve Service", method = "GET", summary = "Returns service according to name and version", responses = {
@@ -507,8 +494,6 @@ public class ServiceServlet extends AbstractValidationsServlet {
@PathParam("serviceVersion") final String serviceVersion, @Context final HttpServletRequest request,
@HeaderParam(value = Constants.USER_ID_HEADER) String userId) throws IOException {
// get modifier id
- User modifier = new User();
- modifier.setUserId(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
Either<Service, ResponseFormat> actionResponse = serviceBusinessLogic.getServiceByNameAndVersion(serviceName, serviceVersion, userId);
@@ -527,7 +512,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@POST
@Path("/services/{serviceId}/distribution/{env}/activate")
- @Tags({@Tag(name = "SDCE-5 APIs")})
+ @Tag(name = "SDCE-5 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Activate distribution", method = "POST", summary = "activate distribution", responses = {
@@ -541,8 +526,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
throws IOException {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
Either<Service, ResponseFormat> distResponse = serviceBusinessLogic.activateDistribution(serviceId, env, modifier, request);
if (distResponse.isRight()) {
@@ -563,7 +547,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@POST
@Path("/services/{serviceId}/distribution/{did}/markDeployed")
- @Tags({@Tag(name = "SDCE-5 APIs")})
+ @Tag(name = "SDCE-5 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Mark distribution as deployed", method = "POST", summary = "relevant audit record will be created", responses = {
@@ -579,8 +563,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@HeaderParam(value = Constants.USER_ID_HEADER) String userId) throws IOException {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
Either<Service, ResponseFormat> distResponse = serviceBusinessLogic.markDistributionAsDeployed(serviceId, did, modifier);
@@ -600,7 +583,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@POST
@Path("/services/{serviceId}/tempUrlToBeDeleted")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(responses = {@ApiResponse(responseCode = "200", description = "OK"),
@@ -608,11 +591,9 @@ public class ServiceServlet extends AbstractValidationsServlet {
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response tempUrlToBeDeleted(@PathParam("serviceId") final String serviceId, @Context final HttpServletRequest request,
@HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
- ServletContext context = request.getSession().getServletContext();
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
Service service = (serviceBusinessLogic.getService(serviceId, modifier)).left().value();
@@ -631,7 +612,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@GET
@Path("/services/{serviceId}/linksMap")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Retrieve Service component relations map", method = "GET", summary = "Returns service components relations", responses = {
@@ -644,8 +625,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
// get modifier id
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug(MODIFIER_ID_IS, userId);
try {
String serviceIdLower = serviceId.toLowerCase();
@@ -667,7 +647,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
@POST
@Path("/services/importService")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Import Service", method = "POST", summary = "Returns imported service", responses = {
@@ -679,26 +659,21 @@ public class ServiceServlet extends AbstractValidationsServlet {
userId = (userId != null) ? userId : request.getHeader(Constants.USER_ID_HEADER);
initSpringFromContext();
String url = request.getMethod() + " " + request.getRequestURI();
- log.debug("Start handle request of {}", url);
- // get modifier id
- User modifier = new User();
- modifier.setUserId(userId);
- log.debug("modifier id is {}", userId);
- Response response;
+ log.debug(START_HANDLE_REQUEST_OF, url);
+ log.debug(MODIFIER_ID_IS, userId);
try {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- performUIImport(responseWrapper, data, request, userId, null);
+ final Wrapper<Response> responseWrapper = performUIImport(data, request, userId, null);
return responseWrapper.getInnerElement();
} catch (IOException | ZipException e) {
BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Import Service");
log.debug("import service failed with exception", e);
- response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
- return response;
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
}
}
- private void performUIImport(Wrapper<Response> responseWrapper, String data, final HttpServletRequest request, String userId,
- String ServiceUniqueId) throws FileNotFoundException, ZipException {
+ private Wrapper<Response> performUIImport(String data, final HttpServletRequest request, String userId,
+ String ServiceUniqueId) throws FileNotFoundException, ZipException {
+ Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
Wrapper<UploadServiceInfo> uploadServiceInfoWrapper = new Wrapper<>();
Wrapper<String> yamlStringWrapper = new Wrapper<>();
@@ -710,6 +685,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(),
yamlStringWrapper.getInnerElement(), ServiceAuthorityEnum, true, ServiceUniqueId);
}
+ return responseWrapper;
}
/**
@@ -729,7 +705,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
*/
@POST
@Path("/services/serviceUUID/{uuid}/importReplaceService")
- @Tags({@Tag(name = "SDCE-2 APIs")})
+ @Tag(name = "SDCE-2 APIs")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Import Service", method = "POST", summary = "Returns imported service", responses = {
@ApiResponse(responseCode = "201", description = "Service created"), @ApiResponse(responseCode = "403", description = "Restricted operation"),
@@ -751,11 +727,9 @@ public class ServiceServlet extends AbstractValidationsServlet {
String url = request.getMethod() + " " + requestURI;
log.debug("importReplaceService,Start handle request of {}", url);
// get modifier id
- User modifier = new User();
- modifier.setUserId(userId);
+ User modifier = new User(userId);
log.debug("importReplaceService,modifier id is {}", userId);
log.debug("importReplaceService,get file:{},fileName:{}", file, file.getName());
- Response response;
ResponseFormat responseFormat = null;
AuditingActionEnum auditingActionEnum = AuditingActionEnum.Import_Replace_Service;
String assetType = "services";
@@ -808,8 +782,9 @@ public class ServiceServlet extends AbstractValidationsServlet {
} catch (IOException | ZipException e) {
BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Import Service");
log.debug("import service failed with exception", e);
- response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
- return response;
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
}
}
+
+ public enum Action {DELETE, MARK_AS_DELETE}
}