Repository: stratos Updated Branches: refs/heads/master eabb22447 -> 3426d775f
Fixed removing network patitions in use Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/27f01783 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/27f01783 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/27f01783 Branch: refs/heads/master Commit: 27f01783f29317c8ee421bcb95c883f85f21dd78 Parents: eabb224 Author: Pubudu Gunatilaka <[email protected]> Authored: Tue May 26 15:37:46 2015 +0530 Committer: Pubudu Gunatilaka <[email protected]> Committed: Tue May 26 15:37:46 2015 +0530 ---------------------------------------------------------------------- .../rest/endpoint/api/StratosApiV41Utils.java | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/27f01783/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index dbcf072..7e17d21 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -2616,9 +2616,30 @@ public class StratosApiV41Utils { public static void removeNetworkPartition(String networkPartitionId) throws RestAPIException, CloudControllerServiceNetworkPartitionNotExistsExceptionException { try { + ApplicationContext[] applicationContexts = AutoscalerServiceClient.getInstance().getApplications(); + if (applicationContexts != null) { + for (ApplicationContext applicationContext : applicationContexts) { + if (applicationContext != null) { + String[] networkPartitions = AutoscalerServiceClient.getInstance().getApplicationNetworkPartitions(applicationContext.getApplicationId()); + if (networkPartitions != null) { + for (int i = 0; i < networkPartitions.length; i++) { + if (networkPartitions[i].equals(networkPartitionId)) { + String message = String.format("Cannot remove the network partition %s, since it is used in application %s", networkPartitionId, applicationContext.getApplicationId()); + log.error(message); + throw new RestAPIException(message); + } + } + } + } + } + } CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance(); serviceClient.removeNetworkPartition(networkPartitionId); - } catch (RemoteException e) { + } catch (AutoscalerServiceAutoScalerExceptionException e) { + String message = e.getMessage(); + log.error(message); + throw new RestAPIException(message, e); + } catch (RemoteException e) { String message = e.getMessage(); log.error(message); throw new RestAPIException(message, e);
