Swap if statement with switch 91/33891/2
authorMunir Ahmad <munir.ahmad@bell.ca>
Sat, 3 Mar 2018 01:08:46 +0000 (20:08 -0500)
committerMunir Ahmad <munir.ahmad@bell.ca>
Wed, 7 Mar 2018 11:39:08 +0000 (11:39 +0000)
Change-Id: Ifc4011741849569b04160d6a009b8149102f6c33
Issue-ID: SO-437
Signed-off-by: Munir Ahmad <munir.ahmad@bell.ca>
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java

index 4e1468c..2c7bd1c 100644 (file)
@@ -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) {
index c87b4f3..3d41992 100644 (file)
@@ -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:
index 79247de..6a77020 100644 (file)
@@ -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) {
index a5e1f6f..d13212a 100644 (file)
@@ -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);
 
index 80d0c48..1f3008a 100644 (file)
@@ -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 ())) {
index 2b7e71a..098ed31 100644 (file)
@@ -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);
 
index 3de945a..c74bb07 100644 (file)
@@ -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 ());
         }
index 0524a85..f908a3f 100644 (file)
@@ -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 ())) {
index d1c1c18..e3af83d 100644 (file)
@@ -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 ());
         }