Handling network partitions without partitions case

Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/26509b49
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/26509b49
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/26509b49

Branch: refs/heads/master
Commit: 26509b49ffa8b0bedbe5655bab65f13f5ed1f4c3
Parents: 1387b28
Author: reka <[email protected]>
Authored: Thu May 21 17:48:22 2015 +0530
Committer: reka <[email protected]>
Committed: Thu May 21 18:15:00 2015 +0530

----------------------------------------------------------------------
 .../services/impl/CloudControllerServiceImpl.java           | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/26509b49/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index b9e0983..6a6f988 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -1436,7 +1436,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean addNetworkPartition(NetworkPartition networkPartition) 
throws NetworkPartitionAlreadyExistsException,
+    public boolean addNetworkPartition(NetworkPartition networkPartition) 
throws
+            NetworkPartitionAlreadyExistsException,
             InvalidNetworkPartitionException {
 
         handleNullObject(networkPartition, "Network Partition is null");
@@ -1453,7 +1454,7 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             throw new NetworkPartitionAlreadyExistsException(message);
         }
 
-        if (networkPartition.getPartitions() != null) {
+        if (networkPartition.getPartitions() != null && 
networkPartition.getPartitions().length != 0) {
             for (Partition partition : networkPartition.getPartitions()) {
                 if (partition != null) {
                     if (log.isInfoEnabled()) {
@@ -1476,6 +1477,10 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                     }
                 }
             }
+        } else {
+            //Following message is shown to the end user in all the the API 
clients(GUI/CLI/Rest API)
+            throw new InvalidNetworkPartitionException(String.format("Network 
partition: " +
+                            "%s doesn't not have any partitions ", 
networkPartition.getId()));
         }
 
         // adding network partition to CC-Context

Reply via email to