diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2018-03-08 06:46:29 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-08 06:46:29 +0000 |
commit | ec4e6d2e150639ec4cdc09aeaea01a66f484f2f6 (patch) | |
tree | 9203212a818f47229292ff499c2ac38ccad4507b /mso-api-handlers | |
parent | bcfb7e24ab050bd530e9aa2c9557386a4b9f82f5 (diff) | |
parent | 2ec6b94890253fec67f4a8a793cb68c0fc1f6535 (diff) |
Merge "Swap if statement with switch"
Diffstat (limited to 'mso-api-handlers')
9 files changed, 291 insertions, 270 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java index 4e1468c4e9..2c7bd1cc36 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java @@ -130,33 +130,35 @@ public class NetworkInfoHandler { if (ar.getVnfType () != null) { vi.setNetworkType (ar.getVnfType ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + + break; } if (ar.getTenantId () != null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java index c87b4f387d..3d419926f1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java @@ -147,24 +147,27 @@ public class NetworkMsoInfraRequest { } // Verify that the elements correspond to the version - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (this.networkInputs.getBackoutOnFailure() != null || this.networkInputs.getAicCloudRegion() != null || - this.networkInputs.getServiceInstanceId() != null) { - throw new ValidationException ("format for v1 version of network request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null || - this.networkInputs.getServiceInstanceId() != null) { - throw new ValidationException ("format for v2 version of network request"); - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (this.networkInputs.getBackoutOnFailure() != null || this.networkInputs.getAicCloudRegion() != null + || + this.networkInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v1 version of network request"); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null || + this.networkInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v2 version of network request"); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null) { + throw new ValidationException("format for v3 version of network request"); + } + break; } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null) { - throw new ValidationException ("format for v3 version of network request"); - } - } switch (action) { case UPDATE: diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java index 79247deca8..6a770202fa 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java @@ -158,33 +158,35 @@ public class NetworkRequestHandler { if (ar.getVnfType () != null) { vi.setNetworkType (ar.getVnfType ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + + break; } if (ar.getTenantId () != null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java index a5e1f6f4e2..d13212a483 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java @@ -148,50 +148,52 @@ public class VnfInfoHandler { if (ar.getVolumeGroupId () != null) { vi.setVolumeGroupId (ar.getVolumeGroupId ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + break; } qr.setVnfInputs (vi); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java index 80d0c48a5e..1f3008aa1a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java @@ -157,26 +157,29 @@ public class VnfMsoInfraRequest { throw new ValidationException ("format for vnf request"); } // Verify that the elements correspond to the version - - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (this.vnfInputs.getVfModuleName () != null || this.vnfInputs.getVfModuleId () != null || - this.vnfInputs.getVfModuleModelName () != null || this.vnfInputs.getAsdcServiceModelVersion () != null || - this.vnfInputs.getBackoutOnFailure() != null || this.vnfInputs.getAicCloudRegion() != null || - this.vnfInputs.getServiceInstanceId () != null) { - throw new ValidationException ("format for v1 version of vnf request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null || this.vnfInputs.getServiceInstanceId () != null) { - throw new ValidationException ("format for v2 version of vnf request"); - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (this.vnfInputs.getVfModuleName() != null || this.vnfInputs.getVfModuleId() != null || + this.vnfInputs.getVfModuleModelName() != null || this.vnfInputs.getAsdcServiceModelVersion() != null + || + this.vnfInputs.getBackoutOnFailure() != null || this.vnfInputs.getAicCloudRegion() != null || + this.vnfInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v1 version of vnf request"); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null + || this.vnfInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v2 version of vnf request"); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null) { + throw new ValidationException("format for v3 version of vnf request"); + } + break; } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null) { - throw new ValidationException ("format for v3 version of vnf request"); - } - } if (!InfraUtils.isActionAllowed (props, "vnf", version, action.value ())) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java index 2b7e71ad9c..098ed31b58 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java @@ -179,50 +179,52 @@ public class VnfRequestHandler { if (ar.getVolumeGroupId () != null) { vi.setVolumeGroupId (ar.getVolumeGroupId ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + break; } qr.setVnfInputs (vi); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java index 3de945a275..c74bb0734d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java @@ -134,43 +134,45 @@ public class VolumeInfoHandler { if (ar.getVnfType () != null) { vi.setVnfType (ar.getVnfType ()); } - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - if (ar.getVnfId () != null) { - vi.setVnfId (ar.getVnfId ()); - } - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + if (ar.getVnfId() != null) { + vi.setVnfId(ar.getVnfId()); + } + break; + } if (ar.getTenantId () != null) { vi.setTenantId (ar.getTenantId ()); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java index 0524a85bf3..f908a3f0d6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java @@ -144,24 +144,27 @@ public class VolumeMsoInfraRequest { // Verify that the elements correspond to the version - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null || - this.volumeInputs.getVfModuleModelName () != null || this.volumeInputs.getAsdcServiceModelVersion () != null || - this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { - throw new ValidationException ("format for v1 version of volume request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null || - this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { - throw new ValidationException ("format for v2 version of volume request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) { - throw new ValidationException ("format for v3 version of volume request"); - } - } + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null || + this.volumeInputs.getVfModuleModelName() != null + || this.volumeInputs.getAsdcServiceModelVersion() != null || + this.volumeInputs.getServiceInstanceId() != null || this.volumeInputs.getVnfId() != null) { + throw new ValidationException("format for v1 version of volume request"); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null || + this.volumeInputs.getServiceInstanceId() != null || this.volumeInputs.getVnfId() != null) { + throw new ValidationException("format for v2 version of volume request"); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) { + throw new ValidationException("format for v3 version of volume request"); + } + break; + } if (!InfraUtils.isActionAllowed (props, "volume", version, action.value ())) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java index d1c1c18e87..e3af83df92 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java @@ -166,43 +166,45 @@ public class VolumeRequestHandler { if (ar.getVnfType () != null) { vi.setVnfType (ar.getVnfType ()); } - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - if (ar.getVnfId () != null) { - vi.setVnfId (ar.getVnfId ()); - } - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + if (ar.getVnfId() != null) { + vi.setVnfId(ar.getVnfId()); + } + break; + } if (ar.getTenantId () != null) { vi.setTenantId (ar.getTenantId ()); } |