aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/CapabilitiesValidation.java28
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/RequirementValidation.java29
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java6
4 files changed, 41 insertions, 32 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index dd8cec347c..dfdae9be5e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -2638,10 +2638,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
Either<List<ComponentInstanceProperty>, ResponseFormat> resultOp = null;
try {
Either<List<ComponentInstanceProperty>, StorageOperationStatus> getComponentInstanceCapabilityProperties = toscaOperationFacade.getComponentInstanceCapabilityProperties(componentId, instanceId, capabilityName, capabilityType, ownerId);
- if(getComponentInstanceCapabilityProperties.isRight()){
- resultOp = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getComponentInstanceCapabilityProperties.right().value()), capabilityType, instanceId, componentId));
+ if(getComponentInstanceCapabilityProperties != null) {
+ if (getComponentInstanceCapabilityProperties.isRight()) {
+ resultOp = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getComponentInstanceCapabilityProperties.right().value()), capabilityType, instanceId, componentId));
+ } else {
+ resultOp = Either.left(getComponentInstanceCapabilityProperties.left().value());
+ }
} else {
- resultOp = Either.left(getComponentInstanceCapabilityProperties.left().value());
+ resultOp = Either.left(new ArrayList<>());
}
} catch(Exception e){
log.error("The exception {} occurred upon the component {} instance {} capability {} properties retrieving. ", componentId, instanceId, capabilityName, e);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/CapabilitiesValidation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/CapabilitiesValidation.java
index 9590ec97d9..726e9dff82 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/CapabilitiesValidation.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/CapabilitiesValidation.java
@@ -91,7 +91,7 @@ public class CapabilitiesValidation {
ResponseFormatManager responseFormatManager) {
String maxOccurrences = capabilityDefinition.getMaxOccurrences();
String minOccurrences = capabilityDefinition.getMinOccurrences();
- if(StringUtils.isNotEmpty(maxOccurrences) && StringUtils.isNotEmpty(minOccurrences)) {
+ if(maxOccurrences != null && minOccurrences != null) {
Either<Boolean, ResponseFormat> capabilityOccurrencesValidationEither =
validateOccurrences(responseFormatManager, minOccurrences,
maxOccurrences);
@@ -189,18 +189,24 @@ public class CapabilitiesValidation {
private Either<Boolean, ResponseFormat> validateOccurrences (
ResponseFormatManager responseFormatManager,
String minOccurrences, String maxOccurrences ) {
- if(StringUtils.isNotEmpty(maxOccurrences)&& "UNBOUNDED".equalsIgnoreCase(maxOccurrences)
- && Integer.parseInt(minOccurrences) >= 0) {
- return Either.left(Boolean.TRUE);
- } else if(Integer.parseInt(minOccurrences) < 0) {
- LOGGER.debug("Invalid occurrences format.low_bound occurrence negative {}", minOccurrences);
+ try {
+ if (StringUtils.isNotEmpty(maxOccurrences) && "UNBOUNDED".equalsIgnoreCase(maxOccurrences)
+ && Integer.parseInt(minOccurrences) >= 0) {
+ return Either.left(Boolean.TRUE);
+ } else if (Integer.parseInt(minOccurrences) < 0) {
+ LOGGER.debug("Invalid occurrences format.low_bound occurrence negative {}", minOccurrences);
+ ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
+ return Either.right(responseFormat);
+ } else if (Integer.parseInt(maxOccurrences) < Integer.parseInt(minOccurrences)) {
+ LOGGER.error("Capability maxOccurrences should be greater than minOccurrences");
+ ResponseFormat errorResponse = responseFormatManager.getResponseFormat(ActionStatus
+ .MAX_OCCURRENCES_SHOULD_BE_GREATER_THAN_MIN_OCCURRENCES);
+ return Either.right(errorResponse);
+ }
+ } catch (NumberFormatException ex) {
+ LOGGER.debug("Invalid occurrences. Only Integer allowed");
ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
return Either.right(responseFormat);
- } else if(Integer.parseInt(maxOccurrences) < Integer.parseInt(minOccurrences)){
- LOGGER.error("Capability maxOccurrences should be greater than minOccurrences");
- ResponseFormat errorResponse = responseFormatManager.getResponseFormat(ActionStatus
- .MAX_OCCURRENCES_SHOULD_BE_GREATER_THAN_MIN_OCCURRENCES);
- return Either.right(errorResponse);
}
return Either.left(Boolean.TRUE);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/RequirementValidation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/RequirementValidation.java
index 0c6a29415a..030684ebb5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/RequirementValidation.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/RequirementValidation.java
@@ -94,7 +94,7 @@ public class RequirementValidation {
ResponseFormatManager responseFormatManager) {
String maxOccurrences = requirementDefinition.getMaxOccurrences();
String minOccurrences = requirementDefinition.getMinOccurrences();
- if(StringUtils.isNotEmpty(maxOccurrences) && StringUtils.isNotEmpty(minOccurrences)) {
+ if(maxOccurrences != null && minOccurrences !=null) {
Either<Boolean, ResponseFormat> requirementOccurrencesValidationEither =
validateOccurrences(responseFormatManager, minOccurrences,
maxOccurrences);
@@ -151,20 +151,25 @@ public class RequirementValidation {
private Either<Boolean, ResponseFormat> validateOccurrences (
ResponseFormatManager responseFormatManager,
String minOccurrences, String maxOccurrences ) {
- if(StringUtils.isNotEmpty(maxOccurrences)&& "UNBOUNDED".equalsIgnoreCase(maxOccurrences)
- && Integer.parseInt(minOccurrences) >= 0) {
- return Either.left(Boolean.TRUE);
- } else if(Integer.parseInt(minOccurrences) < 0) {
- LOGGER.debug("Invalid occurrences format.low_bound occurrence negative {}", minOccurrences);
+ try {
+ if (StringUtils.isNotEmpty(maxOccurrences) && "UNBOUNDED".equalsIgnoreCase(maxOccurrences)
+ && Integer.parseInt(minOccurrences) >= 0) {
+ return Either.left(Boolean.TRUE);
+ } else if (Integer.parseInt(minOccurrences) < 0) {
+ LOGGER.debug("Invalid occurrences format.low_bound occurrence negative {}", minOccurrences);
+ ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
+ return Either.right(responseFormat);
+ } else if (Integer.parseInt(maxOccurrences) < Integer.parseInt(minOccurrences)) {
+ LOGGER.error("Requirement maxOccurrences should be greater than minOccurrences");
+ ResponseFormat errorResponse = responseFormatManager.getResponseFormat(ActionStatus
+ .MAX_OCCURRENCES_SHOULD_BE_GREATER_THAN_MIN_OCCURRENCES);
+ return Either.right(errorResponse);
+ }
+ } catch (NumberFormatException ex) {
+ LOGGER.debug("Invalid occurrences. Only Integer allowed");
ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
return Either.right(responseFormat);
}
- else if(Integer.parseInt(maxOccurrences) < Integer.parseInt(minOccurrences)){
- LOGGER.error("Requirement maxOccurrences should be greater than minOccurrences");
- ResponseFormat errorResponse = responseFormatManager.getResponseFormat(ActionStatus
- .MAX_OCCURRENCES_SHOULD_BE_GREATER_THAN_MIN_OCCURRENCES);
- return Either.right(errorResponse);
- }
return Either.left(Boolean.TRUE);
}
private Either<Boolean, ResponseFormat> isRequirementCapabilityEmpty(
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
index 7bd36eacd1..3e91d74bd1 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
@@ -672,13 +672,10 @@ public class NodeTemplateOperation extends BaseOperation {
Map<String, ListCapabilityDataDefinition> capabilities,
ComponentInstanceDataDefinition componentInstance,
MapListCapabilityDataDefinition calculatedCap) {
- if (capabilities != null) {
MapListCapabilityDataDefinition allCalculatedCap =
new MapListCapabilityDataDefinition(calculatedCap);
populateCapability(capabilities, componentInstance, allCalculatedCap);
return allCalculatedCap;
- }
- return null;
}
private void populateCapability(Map<String, ListCapabilityDataDefinition> capabilities,
@@ -702,14 +699,11 @@ public class NodeTemplateOperation extends BaseOperation {
Map<String, ListRequirementDataDefinition> requirements,
ComponentInstanceDataDefinition componentInstance,
MapListRequirementDataDefinition calculatedReqs) {
- if (requirements != null) {
MapListRequirementDataDefinition allCalculatedReq =
new MapListRequirementDataDefinition(calculatedReqs);
populateRequirement(requirements, componentInstance, allCalculatedReq);
return allCalculatedReq;
- }
- return null;
}
private void populateRequirement(Map<String, ListRequirementDataDefinition> requirements,
ComponentInstanceDataDefinition componentInstance,