summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2019-03-06 17:38:43 +0530
committermojahidi <mojahidul.islam@amdocs.com>2019-03-06 17:40:02 +0530
commitdb91542f3b768260cdf535e05a3976271a70de23 (patch)
tree3692784cfe4ea7ecaa314bec00335f5ea191fc27 /catalog-be
parent289c7e0c82d38f9d17a41bc9712ac8f05c788154 (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')
-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
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(
ass="s">}}.yml" - name: install Open Virtual Network central components package: name: "{{ item }}" state: present with_items: "{{ ovn_central_pkgs }}" - name: enable remote connections to southbound and northbound dbs lineinfile: path: /etc/default/ovn-central line: "OVN_CTL_OPTS=\" --db-sb-create-insecure-remote=yes --db-nb-create-insecure-remote=yes\"" state: present when: ansible_os_family == "Debian" - name: start OVN northbound database services service: name: "{{ ovn_central_service }}" state: restarted - hosts: ovn-controller become: yes vars: ovn_central_ips: "{{ groups['ovn-central'] | map('extract', hostvars, ['ansible_ssh_host']) | join(',') }}" tasks: - name: Load distribution variables include_vars: file: "{{ item }}" with_items: - "{{ ansible_os_family }}.yml" - name: stop the ovn-controller service service: name: "{{ ovn_controller_service }}" state: stopped - name: configure OpenVSwitch databases openvswitch_db: table: Open_vSwitch record: . col: external_ids key: ovn-remote value: \""tcp:{{ item }}:6642"\" with_items: "{{ ovn_central_ips }}" - name: enable overlay network protocols openvswitch_db: table: Open_vSwitch record: . col: external_ids key: ovn-encap-type value: geneve - name: configure the overlay network local endpoint IP address. openvswitch_db: table: Open_vSwitch record: . col: external_ids key: ovn-encap-ip value: "{{ ansible_default_ipv4.address }}" - name: start the ovn-controller service service: name: "{{ ovn_controller_service }}" state: started - name: ensuring that br-int bridge exists openvswitch_bridge: bridge: br-int state: present fail_mode: secure