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/impl/BaseBusinessLogic.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java10
2 files changed, 22 insertions, 13 deletions
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 42e8d9bad1..a7c926e0f7 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
@@ -24,6 +24,12 @@ package org.openecomp.sdc.be.components.impl;
import com.google.gson.JsonElement;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -88,13 +94,6 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-
public abstract class BaseBusinessLogic {
private static final String FAILED_TO_LOCK_COMPONENT_ERROR = "Failed to lock component {} error - {}";
@@ -236,9 +235,19 @@ public abstract class BaseBusinessLogic {
protected void lockComponent(String componentId, Component component, String ecompErrorContext) {
ActionStatus lock = lockElement(componentId, component, ecompErrorContext);
- if ( lock!= ActionStatus.OK ) {
+ if (lock!= ActionStatus.OK) {
+ logAndThrowComponentException(lock, component.getUniqueId(), component.getName());
+ }
+ }
+
+ protected ActionStatus lockComponentAndReturnStatus(final String componentId,
+ final Component component,
+ final String ecompErrorContext) {
+ final ActionStatus lock = lockElement(componentId, component, ecompErrorContext);
+ if (lock!= ActionStatus.OK) {
logAndThrowComponentException(lock, component.getUniqueId(), component.getName());
}
+ return ActionStatus.OK;
}
protected void lockComponent(String componentId, Component component, boolean needLock, String ecompErrorContext) {
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 4e4c5d5027..bd29e9ab81 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
@@ -2676,13 +2676,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return Either.right(booleanResponseFormatEither.right().value());
}
- Either<CINodeFilterDataDefinition, StorageOperationStatus> result;
+ Either<CINodeFilterDataDefinition, StorageOperationStatus> result = null;
- Either<Boolean, ResponseFormat> lockResult = null;
CINodeFilterDataDefinition serviceFilterResult = null;
+ ActionStatus lockStatus = null;
try {
if (lock) {
- lockComponent(storedService.getUniqueId(), storedService, "Add or Update Service Filter on Service");
+ lockStatus = lockComponentAndReturnStatus(storedService.getUniqueId(), storedService, "Add or Update Service Filter on Service");
}
Optional<ComponentInstance> componentInstanceOptional = storedService.getComponentInstanceById(componentInstanceId);
@@ -2711,7 +2711,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
- if (result.isRight()) {
+ if (result != null && result.isRight()) {
janusGraphDao.rollback();
return Either.right(componentsUtils.getResponseFormat(
componentsUtils.convertFromStorageResponse(result.right().value(), ComponentTypeEnum.SERVICE),
@@ -2728,7 +2728,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
} finally {
- if (lockResult != null && lockResult.isLeft() && lockResult.left().value()) {
+ if (ActionStatus.OK == lockStatus) {
graphLockOperation.unlockComponent(storedService.getUniqueId(), NodeTypeEnum.Service);
}
}