diff options
author | mojahidi <mojahidul.islam@amdocs.com> | 2019-03-06 17:38:43 +0530 |
---|---|---|
committer | mojahidi <mojahidul.islam@amdocs.com> | 2019-03-06 17:40:02 +0530 |
commit | db91542f3b768260cdf535e05a3976271a70de23 (patch) | |
tree | 3692784cfe4ea7ecaa314bec00335f5ea191fc27 /catalog-be/src/main/java | |
parent | 289c7e0c82d38f9d17a41bc9712ac8f05c788154 (diff) |
Bug Fix - Requirement and capabilities feature
Fixed - bugs
Change-Id: I6d5dea6ff1e508caf6580c86c430a0bfcbc23c88
Issue-ID: SDC-2142
Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'catalog-be/src/main/java')
3 files changed, 41 insertions, 26 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( |