aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2020-05-20 09:31:52 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-26 10:41:36 +0000
commit1803aa8530b53d9f22dc5815155dd3abdfd99b5a (patch)
treef0cdb508d0470bbc8747b185641eaaf8d269d621 /catalog-be
parent8b19c01ef6a1a074106fe6077bfde07f48248f1d (diff)
Fix for locked component
After add, update or remove node_filter the component was left locked on SDC Issue-ID: SDC-3072 Change-Id: I27058760704bd6261619946becda3612a6386432 Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Diffstat (limited to 'catalog-be')
-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);
}
}