summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java32
2 files changed, 22 insertions, 23 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
index 0356b63793..48cb80d11d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
@@ -276,11 +276,6 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
throw new BusinessLogicException(componentsUtils
.getResponseFormat(ActionStatus.NODE_FILTER_NOT_FOUND, response.right().value().getFormattedMessage()));
}
- boolean wasLocked = false;
- if (shouldLock) {
- lockComponent(component.getUniqueId(), component,"Update Node Filter on Component");
- wasLocked = true;
- }
final Optional<ComponentInstance> componentInstance = getComponentInstance(componentInstanceId,
component);
if (!componentInstance.isPresent()) {
@@ -289,10 +284,14 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
}
CINodeFilterDataDefinition nodeFilterDataDefinition = componentInstance.get().getNodeFilter();
if (nodeFilterDataDefinition == null) {
- throw new BusinessLogicException(componentsUtils
- .getResponseFormat(ActionStatus.NODE_FILTER_NOT_FOUND, response.right().value().getFormattedMessage()));
+ throw new BusinessLogicException(componentsUtils.getResponseFormat(ActionStatus.NODE_FILTER_NOT_FOUND));
}
+ boolean wasLocked = false;
try {
+ if (shouldLock) {
+ lockComponent(component.getUniqueId(), component,"Update Node Filter on Component");
+ wasLocked = true;
+ }
final List<RequirementNodeFilterPropertyDataDefinition> properties = constraints.stream()
.map(this::getRequirementNodeFilterPropertyDataDefinition).collect(Collectors.toList());
final Either<CINodeFilterDataDefinition, StorageOperationStatus> result = nodeFilterOperation
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
index 27daaf2aae..30632e9012 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
@@ -59,28 +59,28 @@ public class NodeFilterValidator {
public static final Set<String> comparableConstraintsOperators =
ImmutableSet.of(ConstraintConvertor.GREATER_THAN_OPERATOR, ConstraintConvertor.LESS_THAN_OPERATOR);
- @Autowired
- protected ToscaOperationFacade toscaOperationFacade;
-
- @Autowired
- protected ComponentsUtils componentsUtils;
+ protected final ToscaOperationFacade toscaOperationFacade;
+ protected final ComponentsUtils componentsUtils;
private static final Logger LOGGER = LoggerFactory.getLogger(NodeFilterValidator.class);
- public Either<Boolean, ResponseFormat> validateComponentInstanceExist(
- final Component component,
- final String componentInstanceId) {
+ @Autowired
+ public NodeFilterValidator(final ToscaOperationFacade toscaOperationFacade,
+ final ComponentsUtils componentsUtils) {
+ this.toscaOperationFacade = toscaOperationFacade;
+ this.componentsUtils = componentsUtils;
+ }
+
+ public Either<Boolean, ResponseFormat> validateComponentInstanceExist(final Component component,
+ final String componentInstanceId) {
if (component == null || StringUtils.isEmpty(componentInstanceId)) {
- LOGGER.debug("Input data cannot be empty");
- return getErrorResponse(ActionStatus.NODE_FILTER_NOT_FOUND);
- }
- if (CollectionUtils.isEmpty(component.getComponentInstances())) {
- LOGGER.debug("Component Instance list is empty");
+ LOGGER.error("Input data cannot be empty");
return getErrorResponse(ActionStatus.NODE_FILTER_NOT_FOUND);
}
- if (component.getComponentInstances().stream()
- .noneMatch(ci -> ci.getUniqueId().equals(componentInstanceId))) {
- LOGGER.debug("Component Instance list is empty");
+ if (CollectionUtils.isEmpty(component.getComponentInstances()) ||
+ component.getComponentInstances().stream()
+ .noneMatch(ci -> ci.getUniqueId().equals(componentInstanceId))) {
+ LOGGER.error("Component Instance list is empty");
return getErrorResponse(ActionStatus.NODE_FILTER_NOT_FOUND);
}
return Either.left(Boolean.TRUE);