You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/12/15 19:17:19 UTC

[1/4] stratos git commit: Removing unused commands in the cli

Repository: stratos
Updated Branches:
  refs/heads/4.1.0-test c665fa13f -> fbcf38471


Removing unused commands in the cli


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

Branch: refs/heads/4.1.0-test
Commit: e11d74382e8521c206fb36f78e0557ce9aba24bd
Parents: c665fa1
Author: Imesh Gunaratne <im...@apache.org>
Authored: Mon Dec 15 11:34:03 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon Dec 15 23:39:56 2014 +0530

----------------------------------------------------------------------
 .../stratos/cli/RestCommandLineService.java     | 439 ++-----------------
 .../apache/stratos/cli/StratosApplication.java  |  52 +--
 .../commands/DeployDeploymentPolicyCommand.java | 138 ------
 .../cli/commands/DeployPartitionCommand.java    | 121 -----
 .../DescribeCartridgeSubscriptionCommand.java   |  95 ----
 .../commands/ListDeploymentPolicyCommand.java   |  65 ---
 .../stratos/cli/commands/ListMemberCommand.java | 136 ------
 .../cli/commands/ListPartitionCommand.java      |  65 ---
 .../commands/UpdateDeploymentPolicyCommand.java | 122 ------
 .../UpdateSubscriptionPropertiesCommand.java    | 135 ------
 10 files changed, 38 insertions(+), 1330 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index 73a24d8..6ee2696 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -132,7 +132,15 @@ public class RestCommandLineService {
         return gsonBuilder.create();
     }
 
-    // Login method. This will authenticate the user
+    /**
+     * Authenticate and login to stratos server.
+     * @param serverURL
+     * @param username
+     * @param password
+     * @param validateLogin
+     * @return
+     * @throws Exception
+     */
     public boolean login(String serverURL, String username, String password, boolean validateLogin) throws Exception {
         try {
             // Avoid validating SSL certificate
@@ -143,8 +151,7 @@ public class RestCommandLineService {
                     return true;
                 }
             };
-            // Create a trust manager that does not validate certificate
-            // chains
+            // Create a trust manager that does not validate certificate chains
             TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
                 public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                     return null;
@@ -171,7 +178,7 @@ public class RestCommandLineService {
                 log.debug("Initialized REST Client for user {}", username);
             }
         } catch (AxisFault e) {
-            System.out.println("Error connecting to the back-end");
+            System.out.println("Error connecting to the stratos server");
             throw new CommandException(e);
         }
 
@@ -213,7 +220,13 @@ public class RestCommandLineService {
         }
     }
 
-    // Initialize the rest client and set username and password of the user
+    /**
+     * Initialize the rest client and set username and password of the user
+     * @param serverURL
+     * @param username
+     * @param password
+     * @throws AxisFault
+     */
     private void initializeRestClient(String serverURL, String username, String password) throws AxisFault {
         HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
         authenticator.setUsername(username);
@@ -236,50 +249,10 @@ public class RestCommandLineService {
         this.restClient = new RestClient(serverURL, username, password);
     }
 
-    public CartridgeDefinitionBean getCartridge(String cartridgeType) throws CommandException {
-        try {
-            Type listType = new TypeToken<ArrayList<CartridgeDefinitionBean>>() {
-            }.getType();
-            List<CartridgeDefinitionBean> cartridgeList = (List<CartridgeDefinitionBean>) restClient.listEntity(ENDPOINT_LIST_CARTRIDGES,
-                    listType, "cartridges");
-
-            for (int i = 0; i < cartridgeList.size(); i++) {
-                CartridgeDefinitionBean cartridge = cartridgeList.get(i);
-                if (cartridgeType.equals(cartridge.getType())) {
-                    return cartridge;
-                }
-            }
-        } catch (Exception e) {
-            String message = "Error in getting cartridge";
-            System.out.println(message);
-            log.error(message, e);
-        }
-        return null;
-    }
-
-    public ArrayList<CartridgeDefinitionBean> listCartridgesByServiceGroup(String serviceGroup) throws CommandException {
-        try {
-            Type listType = new TypeToken<ArrayList<CartridgeDefinitionBean>>() {
-            }.getType();
-            List<CartridgeDefinitionBean> cartridgeList = (List<CartridgeDefinitionBean>) restClient.listEntity(ENDPOINT_LIST_CARTRIDGES,
-                    listType, "cartridges");
-
-            ArrayList<CartridgeDefinitionBean> arrayList = new ArrayList<CartridgeDefinitionBean>();
-            for (int i = 0; i < cartridgeList.size(); i++) {
-                if (serviceGroup.equals(cartridgeList.get(i).getServiceGroup())) {
-                    arrayList.add(cartridgeList.get(i));
-                }
-            }
-            return arrayList;
-        } catch (Exception e) {
-            String message = "Error in listing cartridges";
-            System.out.println(message);
-            log.error(message, e);
-            return null;
-        }
-    }
-
-    // List currently available multi tenant and single tenant cartridges
+    /**
+     * List cartridges
+     * @throws CommandException
+     */
     public void listCartridges() throws CommandException {
         try {
             Type listType = new TypeToken<ArrayList<CartridgeDefinitionBean>>() {
@@ -318,6 +291,11 @@ public class RestCommandLineService {
         }
     }
 
+    /**
+     * Describe a cartridge
+     * @param cartridgeType
+     * @throws CommandException
+     */
     public void describeCartridge(final String cartridgeType) throws CommandException {
         try {
             Type listType = new TypeToken<ArrayList<CartridgeDefinitionBean>>() {
@@ -380,168 +358,6 @@ public class RestCommandLineService {
         }
     }
 
-    // Lists subscribed cartridge info (from alias)
-    public void describeCartridgeSubscription(String alias) throws CommandException {
-        DefaultHttpClient httpClient = new DefaultHttpClient();
-        try {
-            CartridgeWrapper cartridgeWrapper = (CartridgeWrapper) restClient.getEntity(ENDPOINT_GET_CARTRIDGE_OF_TENANT,
-                    CartridgeWrapper.class, "{id}", alias, "cartridge subscription");
-
-            if((cartridgeWrapper == null) || (cartridgeWrapper.getCartridge() == null)) {
-                System.out.println("Cartridge subscription not found: " + alias);
-                return;
-            }
-
-            Cartridge cartridge = cartridgeWrapper.getCartridge();
-
-            // Get LB IP s
-            //Map<String, Set<String>> lbIpMap = getLbIpList(cartridge, httpClient);
-            //final Set<String> lbPrivateIpSet = lbIpMap.get("private");
-            //final Set<String> lbFloatingIpSet = lbIpMap.get("floating");
-            Cartridge[] cartridges = new Cartridge[1];
-            cartridges[0] = cartridge;
-
-            System.out.println("\nSubscribed Cartridges Info\n");
-            System.out.println("\tType : " + cartridge.getCartridgeType());
-            System.out.println("\tName : " + cartridge.getDisplayName());
-            System.out.println("\tVersion : " + cartridge.getVersion());
-            //System.out.println("\tPublic : " + cartridge.getIsPublic());
-            String tenancy = cartridge.isMultiTenantSpecified() ? "Multi-Tenant" : "Single-Tenant";
-            System.out.println("\tTenancy Model	: " + tenancy);
-            System.out.println("\tAlias : " + cartridge.getCartridgeAlias());
-            System.out.println("\tStatus : " + cartridge.getStatus());
-            String instanceCount = String.valueOf(cartridge.getActiveInstances());
-            System.out.println("\tRunning Instances	: " + instanceCount);
-            //System.out.println("\tAccess URL(s) : " + getAccessURLs(cartridge));
-            if (cartridge.getRepoURL() != null) {
-                System.out.println("\tRepo URL : " + cartridge.getRepoURL());
-            }
-            //System.out.println("\tLB Private IP	: " + lbPrivateIpSet.toString());
-            //if (lbFloatingIpSet != null) {
-            //    System.out.println("\tLB Floating IP : " + lbFloatingIpSet.toString());
-            //}
-            //if (cartridge.getProvider().equals("data")) {
-//                System.out.println("\tDB-username : " + cartridge.getDbUserName());
-//                System.out.println("\tDB-password : " + cartridge.getPassword());
-//                System.out.println("\tDB-Host IP (private)  : " + cartridge.getIp());
-//                if (cartridge.getPublicIp() != null) {
-//                    System.out.println("\tDB-Host IP (floating) : "
-//                            + cartridge.getPublicIp());
-//                }
-//            }
-        } catch (Exception e) {
-            String message = "Error in getting cartridge subscription";
-            System.out.println(message);
-            log.error(message, e);
-        }
-    }
-
-    public void listMembersOfCluster(String cartridgeType, String alias) throws CommandException {
-        DefaultHttpClient httpClient = new DefaultHttpClient();
-        try {
-
-            Member[] members = getMembers(cartridgeType, alias, httpClient);
-
-            if (members == null) {
-                // these conditions are handled in the getMembers method
-                return;
-            }
-
-            if (members.length == 0) {
-                if (log.isDebugEnabled()) {
-                    log.debug("No members found");
-                }
-                System.out.println("No members found for the corresponding cluster for type " + cartridgeType
-                        + ", alias " + alias);
-                return;
-            }
-
-            System.out.println("\nList of members in the cluster: " + alias);
-            for (Member member : members) {
-                System.out.println("\n\tServiceName : " + member.getServiceName());
-                System.out.println("\tClusterId : " + member.getClusterId());
-                System.out.println("\tNewtworkPartitionId : " + member.getNetworkPartitionId());
-                System.out.println("\tPartitionId : " + member.getPartitionId());
-                System.out.println("\tStatus : " + member.getStatus());
-                if (member.getLbClusterId() != null) {
-                    System.out.println("\tLBCluster : " + member.getLbClusterId());
-                }
-                System.out.println("\tMemberPrivateIp : " + member.getMemberIp());
-                System.out.println("\tMemberFloatingIp : " + member.getMemberPublicIp());
-                System.out.println("\tMember Properties : " + member.getProperty());
-                System.out.println("\t-----------------------");
-            }
-
-            System.out.println("==================================================");
-            System.out.println("List of LB members for the [cluster]: " + alias);
-
-            // Invoke  clusters/{clusterId}
-            for (Member m : members) {
-                HttpResponse responseCluster = restClient.doGet(httpClient, restClient.getBaseURL() + ENDPOINT_GET_CLUSTER_OF_TENANT
-                        + m.getLbClusterId());
-
-                String responseCode = "" + responseCluster.getStatusLine().getStatusCode();
-                String resultStringCluster = CliUtils.getHttpResponseString(responseCluster);
-
-                GsonBuilder gsonBuilder = new GsonBuilder();
-                Gson gson = gsonBuilder.create();
-
-                if (!responseCode.equals(CliConstants.RESPONSE_OK)) {
-                    ExceptionMapper exception = gson.fromJson(resultStringCluster, ExceptionMapper.class);
-                    System.out.println(exception);
-                    break;
-                }
-                if (resultStringCluster != null && !resultStringCluster.isEmpty()) {
-
-                    printLBs(resultStringCluster);
-                }
-            }
-
-            System.out.println("==================================================");
-
-        } catch (Exception e) {
-            String message = "Error in listing members";
-            System.out.println(message);
-            log.error(message, e);
-        } finally {
-            httpClient.getConnectionManager().shutdown();
-        }
-    }
-
-    private Member[] getMembers(String cartridgeType, String alias, DefaultHttpClient httpClient) throws Exception {
-        try {
-            HttpResponse response = restClient.doGet(httpClient, restClient.getBaseURL()
-                    + ENDPOINT_GET_CLUSTER_OF_TENANT + alias);
-
-            String responseCode = "" + response.getStatusLine().getStatusCode();
-
-            Gson gson = new Gson();
-            if (!responseCode.equals(CliConstants.RESPONSE_OK)) {
-                String resultString = CliUtils.getHttpResponseString(response);
-                ExceptionMapper exception = gson.fromJson(resultString, ExceptionMapper.class);
-                System.out.println(exception);
-                return null;
-            }
-
-            Cluster cluster = getClusterObjectFromString(CliUtils.getHttpResponseString(response));
-
-            if (cluster == null) {
-                System.out.println("No existing subscriptions found for alias " + alias);
-                return null;
-            }
-
-            Member[] members = new Member[cluster.getMember().size()];
-            members = cluster.getMember().toArray(members);
-
-            return members;
-        } catch (Exception e) {
-            String message = "Error in listing members";
-            System.out.println(message);
-            log.error(message, e);
-            return null;
-        }
-    }
-
     private Cluster getClusterObjectFromString(String resultString) {
         String tmp;
         if (resultString.startsWith("{\"cluster\"")) {
@@ -553,41 +369,6 @@ public class RestCommandLineService {
         return gson.fromJson(resultString, Cluster.class);
     }
 
-    private void printLBs(String resultString) {
-
-        Cluster cluster = getClusterObjectFromString(resultString);
-
-        if (cluster == null) {
-            System.out.println("Subscribe cartridge list is null");
-            return;
-        }
-
-        Member[] members = new Member[cluster.getMember().size()];
-        members = cluster.getMember().toArray(members);
-
-        if (members.length == 0) {
-            if (log.isDebugEnabled()) {
-                log.debug("No subscribed cartridges found");
-            }
-            System.out.println("There are no subscribed cartridges");
-            return;
-        }
-
-        for (Member member : members) {
-            System.out.println("\n\tServiceName : " + member.getServiceName());
-            System.out.println("\tClusterId : " + member.getClusterId());
-            System.out.println("\tNewtworkPartitionId : " + member.getNetworkPartitionId());
-            System.out.println("\tPartitionId : " + member.getPartitionId());
-            System.out.println("\tStatus : " + member.getStatus());
-            if (member.getLbClusterId() != null) {
-                System.out.println("\tLBCluster : " + member.getLbClusterId());
-            }
-            System.out.println("\tMemberPrivateIp : " + member.getMemberIp());
-            System.out.println("\tMemberFloatingIp : " + member.getMemberPublicIp());
-            System.out.println("\t-----------------------");
-        }
-    }
-
     // This method helps to create the new tenant
     public void addTenant(String admin, String firstName, String lastaName, String password, String domain, String email)
             throws CommandException {
@@ -860,11 +641,6 @@ public class RestCommandLineService {
         restClient.undeployEntity(ENDPOINT_UNDEPLOY_CARTRIDGE, "cartridge", id);
     }
 
-    // This method helps to deploy partitions
-    public void deployPartition(String partitionDefinition) throws CommandException {
-        restClient.deployEntity(ENDPOINT_DEPLOY_PARTITION, partitionDefinition, "partition");
-    }
-
     // This method helps to deploy autoscalling polices
     public void deployAutoscalingPolicy(String autoScalingPolicy) throws CommandException {
         restClient.deployEntity(ENDPOINT_DEPLOY_AUTOSCALING_POLICY, autoScalingPolicy, "autoscaling policy");
@@ -908,52 +684,6 @@ public class RestCommandLineService {
         }
     }
 
-    // This method helps to deploy deployment polices
-    public void deployDeploymentPolicy(String deploymentPolicy) throws CommandException {
-        restClient.deployEntity(ENDPOINT_DEPLOY_DEPLOYMENT_POLICY, deploymentPolicy, "deployment policy");
-    }
-
-    // This method helps to update a deployment policy
-    public void updateDeploymentPolicy(String deploymentPolicy) throws CommandException {
-        restClient.updateEntity(ENDPOINT_UPDATE_DEPLOYMENT_POLICY, deploymentPolicy, "deployment policy");
-    }
-
-    // This method lists available partitions
-    public void listPartitions() throws CommandException {
-        try {
-            Type listType = new TypeToken<ArrayList<Partition>>() {
-            }.getType();
-            List<Partition> list = (List<Partition>) restClient.listEntity(ENDPOINT_LIST_PARTITIONS,
-                    listType, "partitions");
-
-            if ((list == null) || (list.size() == 0)) {
-                System.out.println("No partitions found");
-                return;
-            }
-
-            RowMapper<Partition> rowMapper = new RowMapper<Partition>() {
-
-                public String[] getData(Partition partition) {
-                    String[] data = new String[3];
-                    data[0] = partition.getId();
-                    data[1] = partition.getProvider();
-                    data[2] = partition.getIsPublic() ? "Public" : "Private";
-                    return data;
-                }
-            };
-
-            Partition[] partitions = new Partition[list.size()];
-            partitions = list.toArray(partitions);
-
-            System.out.println("Partitions found:");
-            CliUtils.printTable(partitions, rowMapper, "ID", "Provider", "Accessibility");
-        } catch (Exception e) {
-            String message = "Error in listing partitions";
-            System.out.println(message);
-            log.error(message, e);
-        }
-    }
-
     public void listAutoscalingPolicies() throws CommandException {
         try {
             Type listType = new TypeToken<ArrayList<AutoscalePolicy>>() {
@@ -988,40 +718,6 @@ public class RestCommandLineService {
         }
     }
 
-    public void listDeploymentPolicies() throws CommandException {
-        try {
-            Type listType = new TypeToken<ArrayList<DeploymentPolicy>>() {
-            }.getType();
-            List<DeploymentPolicy> list = (List<DeploymentPolicy>) restClient.listEntity(ENDPOINT_LIST_DEPLOYMENT_POLICIES,
-                    listType, "deployment policies");
-
-            if ((list == null) || (list.size() == 0)) {
-                System.out.println("No deployment policies found");
-                return;
-            }
-
-            RowMapper<DeploymentPolicy> rowMapper = new RowMapper<DeploymentPolicy>() {
-
-                public String[] getData(DeploymentPolicy policy) {
-                    String[] data = new String[2];
-                    data[0] = policy.getApplicationId();
-                    data[1] = policy.getIsPublic() ? "Public" : "Private";
-                    return data;
-                }
-            };
-
-            DeploymentPolicy[] array = new DeploymentPolicy[list.size()];
-            array = list.toArray(array);
-
-            System.out.println("Deployment policies found:");
-            CliUtils.printTable(array, rowMapper, "ID", "Accessibility");
-        } catch (Exception e) {
-            String message = "Error in listing deployment policies";
-            System.out.println(message);
-            log.error(message, e);
-        }
-    }
-
     public void describeDeploymentPolicy(String id) throws CommandException {
         try {
             DeploymentPolicy policy = (DeploymentPolicy) restClient.getEntity(ENDPOINT_GET_DEPLOYMENT_POLICY,
@@ -1198,12 +894,6 @@ public class RestCommandLineService {
         }
     }
 
-    // This method helps to update cartridge subscription properties
-    public void updateSubscritptionProperties(String alias, String subscriptionJson) {
-        String url = ENDPOINT_UPDATE_SUBSCRIPTION_PROPERTIES.replace("{subscriptionAlias}", alias);
-        restClient.updateEntity(url, subscriptionJson, "subscription alias: "+alias);
-    }
-
     // This method helps to deploy service groups
     public void deployServiceGroup (String entityBody) {
         restClient.deployEntity(ENDPOINT_DEPLOY_SERVICE_GROUP, entityBody, "service group");
@@ -1267,19 +957,6 @@ public class RestCommandLineService {
         }
     }
 
-    // This will return access url from a given cartridge
-    private String getAccessURLs(CartridgeDefinitionBean cartridge) {
-        List<PortMappingBean> portMappings = cartridge.getPortMapping();
-        StringBuilder urlBuilder = new StringBuilder();
-
-        for (PortMappingBean portMapping : portMappings) {
-            String url = portMapping.getProtocol() + "://" + cartridge.getHost() + ":" + portMapping.getProxyPort() + "/";
-            urlBuilder.append(url).append(", ");
-        }
-
-        return urlBuilder.toString();
-    }
-
     // This is for handle exception
     private void handleException(String key, Exception e, Object... args) throws CommandException {
         if (log.isDebugEnabled()) {
@@ -1295,66 +972,4 @@ public class RestCommandLineService {
         System.out.println(message);
         throw new CommandException(message, e);
     }
-
-    // This class is to convert JSON string to Cartridge object
-    public class CartridgeWrapper {
-        private Cartridge cartridge;
-
-        public Cartridge getCartridge() {
-            return cartridge;
-        }
-
-        public void setCartridge(Cartridge cartridge) {
-            this.cartridge = cartridge;
-        }
-
-        public CartridgeWrapper() {
-        }
-    }
-
-    public boolean isMultiTenant(String type) throws CommandException {
-        DefaultHttpClient httpClient = new DefaultHttpClient();
-        try {
-            HttpResponse response = restClient.doGet(httpClient, restClient.getBaseURL() + ENDPOINT_LIST_CARTRIDGES);
-
-            String responseCode = "" + response.getStatusLine().getStatusCode();
-            String resultString = CliUtils.getHttpResponseString(response);
-            if (resultString == null) {
-                return false;
-            }
-
-            GsonBuilder gsonBuilder = new GsonBuilder();
-            Gson gson = gsonBuilder.create();
-
-            if (!responseCode.equals(CliConstants.RESPONSE_OK)) {
-                ExceptionMapper exception = gson.fromJson(resultString, ExceptionMapper.class);
-                System.out.println(exception);
-                return false;
-            }
-
-            Type listType = new TypeToken<ArrayList<CartridgeDefinitionBean>>() {}.getType();
-            List<CartridgeDefinitionBean> cartridgeList = gson.fromJson(resultString, listType);
-
-            if (cartridgeList == null) {
-                System.out.println("Available cartridge list is null");
-                return false;
-            }
-
-            ArrayList<CartridgeDefinitionBean> multiTenetCartridge = new ArrayList<CartridgeDefinitionBean>();
-
-            for (CartridgeDefinitionBean cartridge : cartridgeList) {
-                if (cartridge.isMultiTenant() && cartridge.getType().equals(type)) {
-                    multiTenetCartridge.add(cartridge);
-                }
-            }
-
-            return multiTenetCartridge.size() > 0;
-
-        } catch (Exception e) {
-            handleException("Exception in listing cartridges", e);
-            return false;
-        } finally {
-            httpClient.getConnectionManager().shutdown();
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
index 57eb35d..0298742 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
@@ -18,23 +18,7 @@
  */
 package org.apache.stratos.cli;
 
-import static org.apache.stratos.cli.utils.CliConstants.STRATOS_DIR;
-import static org.apache.stratos.cli.utils.CliConstants.STRATOS_HISTORY_DIR;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.*;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.text.StrTokenizer;
 import org.apache.commons.validator.routines.UrlValidator;
@@ -47,6 +31,16 @@ import org.apache.stratos.cli.utils.CliConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+import static org.apache.stratos.cli.utils.CliConstants.STRATOS_DIR;
+import static org.apache.stratos.cli.utils.CliConstants.STRATOS_HISTORY_DIR;
+
 public class StratosApplication extends CommandLineApplication<StratosCommandContext> {
 
 	private static final Logger logger = LoggerFactory.getLogger(StratosApplication.class);
@@ -123,9 +117,6 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
         command = new DeployCartridgeCommand();
         commands.put(command.getName(), command);
 
-        command = new DeployPartitionCommand();
-        commands.put(command.getName(), command);
-
         command = new DeployAutoscalingPolicyCommand();
         commands.put(command.getName(), command);
 
@@ -135,18 +126,9 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
         command = new UndeployCartridgeDefinitionCommand();
         commands.put(command.getName(), command);
 
-        command = new DeployDeploymentPolicyCommand();
-        commands.put(command.getName(), command);
-
         command = new ListAutoscalePolicyCommand();
         commands.put(command.getName(), command);
 
-        command = new ListDeploymentPolicyCommand();
-        commands.put(command.getName(), command);
-		
-		command = new ListMemberCommand();
-		commands.put(command.getName(), command);
-
         command = new DescribeCartridgeCommand();
         commands.put(command.getName(), command);
 
@@ -155,9 +137,6 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
 
         command = new DescribeAutoScalingPolicyCommand();
         commands.put(command.getName(), command);
-        
-        command = new DescribeCartridgeSubscriptionCommand();
-        commands.put(command.getName(), command);
 		
 		command = new SyncCommand();
 		commands.put(command.getName(), command);
@@ -185,15 +164,6 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
 
         command = new UpdateKubernetesHostCommand();
         commands.put(command.getName(), command);
-        
-        command = new UpdateSubscriptionPropertiesCommand();
-        commands.put(command.getName(), command);
-
-        /*command = new UpdateAutoscalingPolicyCommand();
-        commands.put(command.getName(), command);
-
-        command = new UpdateDeploymentPolicyCommand();
-        commands.put(command.getName(), command);*/
 
         command = new DeployServiceGroupCommand();
         commands.put(command.getName(), command);

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployDeploymentPolicyCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployDeploymentPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployDeploymentPolicyCommand.java
deleted file mode 100644
index f444894..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployDeploymentPolicyCommand.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import org.apache.commons.cli.*;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class DeployDeploymentPolicyCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(DeployDeploymentPolicyCommand.class);
-
-    private final Options options;
-
-    public DeployDeploymentPolicyCommand(){
-        options = constructOptions();
-    }
-
-    private Options constructOptions() {
-        final Options options = new Options();
-
-        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Deployment policy deployment resource path");
-        resourcePath.setArgName("resource path");
-        options.addOption(resourcePath);
-
-        return options;
-    }
-
-    public String getName() {
-        return CliConstants.DEPLOYMENT_POLICY_DEPLOYMENT;
-    }
-
-    public String getDescription() {
-        return "Add new deployment policy";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-
-        if (args != null && args.length > 0) {
-            String resourcePath = null;
-            String deploymentPolicyDeployment = null;
-
-            final CommandLineParser parser = new GnuParser();
-            CommandLine commandLine;
-
-            try {
-                commandLine = parser.parse(options, args);
-
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Deployment policy deployment");
-                }
-
-                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Resource path option is passed");
-                    }
-                    resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                    deploymentPolicyDeployment = readResource(resourcePath);
-                }
-
-                if (resourcePath == null) {
-                    System.out.println("usage: " + getName() + " [-p <resource path>]");
-                    return CliConstants.COMMAND_FAILED;
-                }
-
-                RestCommandLineService.getInstance().deployDeploymentPolicy(deploymentPolicyDeployment);
-                return CliConstants.COMMAND_SUCCESSFULL;
-
-            } catch (ParseException e) {
-                if (logger.isErrorEnabled()) {
-                    logger.error("Error parsing arguments", e);
-                }
-                System.out.println(e.getMessage());
-                return CliConstants.COMMAND_FAILED;
-            } catch (IOException e) {
-                //e.printStackTrace();
-                System.out.println("Invalid resource path");
-                return CliConstants.COMMAND_FAILED;
-            }
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    private String readResource(String fileName) throws IOException {
-        BufferedReader br = new BufferedReader(new FileReader(fileName));
-        try {
-            StringBuilder sb = new StringBuilder();
-            String line = br.readLine();
-
-            while (line != null) {
-                sb.append(line);
-                sb.append("\n");
-                line = br.readLine();
-            }
-            return sb.toString();
-        } finally {
-            br.close();
-        }
-    }
-
-    public Options getOptions() {
-        return options;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployPartitionCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployPartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployPartitionCommand.java
deleted file mode 100644
index 5d84c19..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployPartitionCommand.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import org.apache.commons.cli.*;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.apache.stratos.cli.utils.CliUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class DeployPartitionCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(DeployPartitionCommand.class);
-
-    private final Options options;
-
-    public DeployPartitionCommand(){
-        options = constructOptions();
-    }
-
-    private Options constructOptions() {
-        final Options options = new Options();
-
-        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Partition deployment resource path");
-        resourcePath.setArgName("resource path");
-        options.addOption(resourcePath);
-
-        return options;
-    }
-
-    public String getName() {
-        return CliConstants.PARTITION_DEPLOYMENT;
-    }
-
-    public String getDescription() {
-        return "Add new partition deployment";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-
-        if (args != null && args.length > 0) {
-            String resourcePath = null;
-            String partionDeployment = null;
-
-            final CommandLineParser parser = new GnuParser();
-            CommandLine commandLine;
-
-            try {
-                commandLine = parser.parse(options, args);
-
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Partition deployment");
-                }
-
-                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Resource path option is passed");
-                    }
-                    resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                    partionDeployment = CliUtils.readResource(resourcePath);
-                }
-
-                if (resourcePath == null) {
-                    System.out.println("usage: " + getName() + " [-p <resource path>]");
-                    return CliConstants.COMMAND_FAILED;
-                }
-
-                RestCommandLineService.getInstance().deployPartition(partionDeployment);
-                return CliConstants.COMMAND_SUCCESSFULL;
-
-            } catch (ParseException e) {
-                if (logger.isErrorEnabled()) {
-                    logger.error("Error parsing arguments", e);
-                }
-                System.out.println(e.getMessage());
-                return CliConstants.COMMAND_FAILED;
-            } catch (IOException e) {
-                System.out.println("Invalid resource path");
-                return CliConstants.COMMAND_FAILED;
-            }
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    public Options getOptions() {
-        return options;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeSubscriptionCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeSubscriptionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeSubscriptionCommand.java
deleted file mode 100644
index ecac615..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeSubscriptionCommand.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DescribeCartridgeSubscriptionCommand implements Command<StratosCommandContext>{
-	
-	private static final Logger logger = LoggerFactory.getLogger(DescribeCartridgeSubscriptionCommand.class);
-	
-	private final Options options;
-	
-	public DescribeCartridgeSubscriptionCommand() {
-		options = constructOptions();
-	}
-	
-	/**
-	 * Construct Options.
-	 * 
-	 * @return Options expected from command-line.
-	 */
-	private Options constructOptions() {
-
-		final Options options = new Options();
-		return options;
-	}
-	
-	@Override
-	public String getName() {
-		return "describe-cartridge-subscription";
-	}
-
-	@Override
-	public String getDescription() {
-		return "Describe cartridge subscription";
-	}
-
-	@Override
-	public String getArgumentSyntax() {
-		return "[cartridge-subscription-alias]";
-	}
-
-	@Override
-	public Options getOptions() {
-		return options;
-	}
-
-	@Override
-	public int execute(StratosCommandContext context, String[] args) throws CommandException {
-		if (logger.isDebugEnabled()) {
-			logger.debug("Executing {} command...", getName());
-		}
-		
-		if (args != null && args.length > 0) {
-			String cartridgeSubscriptionAlias = args[0];
-
-            if(StringUtils.isBlank(cartridgeSubscriptionAlias)){
-                System.out.println("Please specify a non blank alias");
-                return CliConstants.COMMAND_FAILED;
-            }
-            else{
-                RestCommandLineService.getInstance().describeCartridgeSubscription(cartridgeSubscriptionAlias);
-                return CliConstants.COMMAND_SUCCESSFULL;
-            }
-		} else {
-			context.getStratosApplication().printUsage(getName());
-			return CliConstants.COMMAND_FAILED;
-		}
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeploymentPolicyCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeploymentPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeploymentPolicyCommand.java
deleted file mode 100644
index 752bcb5..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeploymentPolicyCommand.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ListDeploymentPolicyCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(ListAutoscalePolicyCommand.class);
-
-    public ListDeploymentPolicyCommand() {
-    }
-
-    public String getName() {
-        return CliConstants.LIST_DEPLOYMENT_POLICIES;
-    }
-
-    public String getDescription() {
-        return "List available deployment policies";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-        if (args == null || args.length == 0) {
-            RestCommandLineService.getInstance().listDeploymentPolicies();
-            return CliConstants.COMMAND_SUCCESSFULL;
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    public Options getOptions() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java
deleted file mode 100644
index cbdf039..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import org.apache.commons.cli.*;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ListMemberCommand implements Command<StratosCommandContext> {
-    private static final Logger logger = LoggerFactory.getLogger(ListMemberCommand.class);
-
-
-    private final Options options;
-
-	public ListMemberCommand() {
-		options = constructOptions();
-	}
-
-	/**
-	 * Construct Options.
-	 *
-	 * @return Options expected from command-line.
-	 */
-	private Options constructOptions() {
-		final Options options = new Options();
-
-        Option type = new Option(CliConstants.CARTRIDGE_TYPE_OPTION, CliConstants.CARTRIDGE_TYPE_LONG_OPTION,
-                true, "Cartridge Type");
-        type.setArgName("cartridge-type");
-        options.addOption(type);
-
-        Option alias = new Option(CliConstants.ALIAS_OPTION, CliConstants.ALIAS_LONG_OPTION,
-                true, "subscription alias");
-        alias.setArgName("alias");
-        options.addOption(alias);
-
-        return options;
-	}
-    @Override
-    public String getName() {
-        return CliConstants.LIST_MEMBERS;
-    }
-
-    @Override
-    public String getDescription() {
-        return "List of members in a cluster";
-    }
-
-    @Override
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    @Override
-    public Options getOptions() {
-        return options;
-    }
-
-    @Override
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-			logger.debug("Executing {} command...", getName());
-		}
-		if (args != null && args.length > 0) {
-			String type = null;
-			String alias = null;
-
-			final CommandLineParser parser = new GnuParser();
-			CommandLine commandLine;
-			try {
-				commandLine = parser.parse(options, args);
-				if (logger.isDebugEnabled()) {
-					logger.debug("Subscribing to {} cartridge with alias {}", type, alias);
-				}
-
-                if (commandLine.hasOption(CliConstants.CARTRIDGE_TYPE_OPTION)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Autoscaling policy option is passed");
-                    }
-                    type = commandLine.getOptionValue(CliConstants.CARTRIDGE_TYPE_OPTION);
-                }
-                if (commandLine.hasOption(CliConstants.ALIAS_OPTION)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Deployment policy option is passed");
-                    }
-                    alias = commandLine.getOptionValue(CliConstants.ALIAS_OPTION);
-                }
-
-                if (type == null) {
-                    System.out.println("Cartridge type is required.");
-                    context.getStratosApplication().printUsage(getName());
-                    return CliConstants.COMMAND_FAILED;
-                }
-
-                if (alias == null) {
-                    System.out.println("alis is required...");
-                    context.getStratosApplication().printUsage(getName());
-                    return CliConstants.COMMAND_FAILED;
-                }
-                RestCommandLineService.getInstance().listMembersOfCluster(type, alias);
-
-				return CliConstants.COMMAND_SUCCESSFULL;
-			} catch (ParseException e) {
-				if (logger.isErrorEnabled()) {
-					logger.error("Error parsing arguments", e);
-				}
-				System.out.println(e.getMessage());
-				return CliConstants.COMMAND_FAILED;
-			}
-		} else {
-			context.getStratosApplication().printUsage(getName());
-			return CliConstants.COMMAND_FAILED;
-		}
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListPartitionCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListPartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListPartitionCommand.java
deleted file mode 100644
index ce75bfd..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListPartitionCommand.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import org.apache.commons.cli.*;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ListPartitionCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(ListPartitionCommand.class);
-
-    public ListPartitionCommand(){
-    }
-
-    public String getName() {
-        return CliConstants.LIST_PARTITION;
-    }
-
-    public String getDescription() {
-        return "List available partitions";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-        if (args == null || args.length == 0) {
-            RestCommandLineService.getInstance().listPartitions();
-            return CliConstants.COMMAND_SUCCESSFULL;
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    public Options getOptions() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateDeploymentPolicyCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateDeploymentPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateDeploymentPolicyCommand.java
deleted file mode 100644
index f8d487c..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateDeploymentPolicyCommand.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import org.apache.commons.cli.*;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.apache.stratos.cli.utils.CliUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class UpdateDeploymentPolicyCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(UpdateDeploymentPolicyCommand.class);
-
-    private final Options options;
-
-    public UpdateDeploymentPolicyCommand(){
-        options = constructOptions();
-    }
-
-    public Options getOptions() {
-        return options;
-    }
-
-    private Options constructOptions() {
-        final Options options = new Options();
-
-        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Deployment policy resource path");
-        resourcePath.setArgName("resource path");
-        options.addOption(resourcePath);
-
-        return options;
-    }
-
-    public String getName() {
-        return "update-deployment-policy";
-    }
-
-    public String getDescription() {
-        return "Update deployment policy";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-
-        if (args != null && args.length > 0) {
-            String resourcePath = null;
-            String deploymentPolicyDeployment = null;
-
-            final CommandLineParser parser = new GnuParser();
-            CommandLine commandLine;
-
-            try {
-                commandLine = parser.parse(options, args);
-
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Updating deployment policy");
-                }
-
-                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Resource path option is passed");
-                    }
-                    resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                    deploymentPolicyDeployment = CliUtils.readResource(resourcePath);
-                }
-
-                if (resourcePath == null) {
-                    System.out.println("usage: " + getName() + " [-p <resource path>]");
-                    return CliConstants.COMMAND_FAILED;
-                }
-
-                RestCommandLineService.getInstance().updateDeploymentPolicy(deploymentPolicyDeployment);
-                return CliConstants.COMMAND_SUCCESSFULL;
-
-            } catch (ParseException e) {
-                if (logger.isErrorEnabled()) {
-                    logger.error("Error parsing arguments", e);
-                }
-                System.out.println(e.getMessage());
-                return CliConstants.COMMAND_FAILED;
-            } catch (IOException ignore) {
-                System.out.println("Invalid resource path");
-                return CliConstants.COMMAND_FAILED;
-            }
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e11d7438/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateSubscriptionPropertiesCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateSubscriptionPropertiesCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateSubscriptionPropertiesCommand.java
deleted file mode 100644
index 4f400a2..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateSubscriptionPropertiesCommand.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.stratos.cli.commands;
-
-import java.io.IOException;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.stratos.cli.Command;
-import org.apache.stratos.cli.RestCommandLineService;
-import org.apache.stratos.cli.StratosCommandContext;
-import org.apache.stratos.cli.exception.CommandException;
-import org.apache.stratos.cli.utils.CliConstants;
-import org.apache.stratos.cli.utils.CliUtils;
-
-public class UpdateSubscriptionPropertiesCommand implements Command<StratosCommandContext> {
-
-	private static final Logger logger = LoggerFactory.getLogger(UpdateSubscriptionPropertiesCommand.class);
-	
-	private final Options options;
-
-	public UpdateSubscriptionPropertiesCommand() {
-	    options = constructOptions();
-	}
-	
-	/**
-     * Construct Options.
-     *
-     * @return Options expected from command-line.
-     */
-    private Options constructOptions() {
-        final Options options = new Options();
-
-        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Update subscription properties resource path");
-        resourcePath.setArgName("resource path");
-        options.addOption(resourcePath);
-        
-        return options;
-    }
-
-	@Override
-	public String getName() {
-		return CliConstants.UPDATE_SUBSCRIPTION_ACTION;
-	}
-
-	@Override
-	public String getDescription() {
-		return "Update a previously made subscription.";
-	}
-
-	@Override
-	public String getArgumentSyntax() {
-		return "[cartridge-subscription-alias]";
-	}
-
-	@Override
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-
-        final CommandLineParser parser = new GnuParser();
-        CommandLine commandLine;
-        String[] remainingArgs = null;
-        String resourcePath = null, subscriptionJson = null;
-        try {
-
-            commandLine = parser.parse(options, args);
-            remainingArgs = commandLine.getArgs();
-
-            if (remainingArgs != null && remainingArgs.length == 1) {
-
-                String alias = remainingArgs[0];
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Getting info {}", alias);
-                }
-
-                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("{} option is passed", CliConstants.RESOURCE_PATH);
-                    }
-                    try {
-                        resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                        subscriptionJson = CliUtils.readResource(resourcePath);
-                    } catch (IOException e) {
-                        System.out.println("Invalid resource path");
-                        return CliConstants.COMMAND_FAILED;
-                    }
-                }
-
-                RestCommandLineService.getInstance().updateSubscritptionProperties(alias, subscriptionJson);
-                return CliConstants.COMMAND_SUCCESSFULL;
-            } else {
-                context.getStratosApplication().printUsage(getName());
-                return CliConstants.COMMAND_FAILED;
-            }
-        } catch (ParseException e) {
-            if (logger.isErrorEnabled()) {
-                logger.error("Error parsing arguments", e);
-            }
-            System.out.println(e.getMessage());
-            return CliConstants.COMMAND_FAILED;
-        }
-
-    }
-
-	@Override
-	public Options getOptions() {
-		return options;
-	}
-
-}


[3/4] stratos git commit: Refining application deployment process

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/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 8a2f8a7..274dd8f 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
@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.stub.*;
 import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
+import org.apache.stratos.autoscaler.stub.pojo.ApplicationContextStatus;
 import org.apache.stratos.cloud.controller.stub.*;
 import org.apache.stratos.cloud.controller.stub.domain.CartridgeConfig;
 import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
@@ -82,6 +83,7 @@ public class StratosApiV41Utils {
     public static final String DEVICE_NAME = "volume.device.name";
     public static final String VOLUME_ID = "volume.id";
     public static final String TENANT_RANGE_ALL = "*";
+    public static final String APPLICATION_STATUS_DEPLOYED = "Deployed";
 
     private static Log log = LogFactory.getLog(StratosApiV41Utils.class);
     private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager();
@@ -108,7 +110,7 @@ public class StratosApiV41Utils {
         }
         log.info("Successfully deployed cartridge: [type] " + cartridgeDefinitionBean.getType());
     }
-    
+
     public static void deleteCartridgeDefinition(String cartridgeType) throws RestAPIException {
 
         CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
@@ -185,11 +187,11 @@ public class StratosApiV41Utils {
             throw new RestAPIException(msg, e);
         }
     }
-    
+
     public static List<CartridgeDefinitionBean> getCartridgesByFilter(String filter, String criteria, ConfigurationContext configurationContext)
 			throws RestAPIException {
 		List<CartridgeDefinitionBean> cartridges = null;
-		
+
 		if (filter.equals("singleTenant")) {
 			cartridges = getAvailableCartridges(null, false, configurationContext);
 		} else if (filter.equals("multiTenant")) {
@@ -199,14 +201,14 @@ public class StratosApiV41Utils {
 		} else if (filter.equals("provider")) {
 			cartridges = getAvailableCartridgesByProvider(criteria, configurationContext);
 		}
-		
+
 		return cartridges;
 	}
-	
+
 	public static CartridgeDefinitionBean getCartridgeByFilter(String filter, String cartridgeType, ConfigurationContext configurationContext)
 	throws RestAPIException {
 		List<CartridgeDefinitionBean> cartridges = getCartridgesByFilter(filter, null, configurationContext);
-		
+
 		for (CartridgeDefinitionBean cartridge : cartridges) {
 			if (cartridge.getType().equals(cartridgeType)) {
 				return cartridge;
@@ -216,7 +218,7 @@ public class StratosApiV41Utils {
 		log.error(msg);
 		throw new RestAPIException(msg);
 	}
-    
+
     private static List<CartridgeDefinitionBean> getAvailableLbCartridges(Boolean multiTenant,
                                                     ConfigurationContext configurationContext) throws RestAPIException {
         List<CartridgeDefinitionBean> cartridges = getAvailableCartridges(null, multiTenant,
@@ -496,9 +498,9 @@ public class StratosApiV41Utils {
         }
         return true;
     }
-    	
+
     // Util methods to get the service clients
-    
+
     private static CloudControllerServiceClient getCloudControllerServiceClient() throws RestAPIException {
 
         try {
@@ -610,28 +612,8 @@ public class StratosApiV41Utils {
 
         return PojoConverter.populateAutoscalePojo(autoscalePolicy);
     }
-    
-    // Util methods for Deployment policies
-    
-    public static org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy[]
-    getDeploymentPolicies() throws RestAPIException {
-
-        DeploymentPolicy[] deploymentPolicies = null;
-        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
-        if (autoscalerServiceClient != null) {
-            try {
-                deploymentPolicies = autoscalerServiceClient.getDeploymentPolicies();
-            } catch (RemoteException e) {
-                String errorMsg = "Error getting available deployment policies. Cause : " + e.getMessage();
-                log.error(errorMsg, e);
-                throw new RestAPIException(errorMsg, e);
-            }
-        }
-
-
-        return PojoConverter.populateDeploymentPolicyPojos(deploymentPolicies);
-    }
 
+    // Util methods for Deployment policies
     public static org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy
     getDeploymentPolicy(String deploymentPolicyId) throws RestAPIException {
 
@@ -677,7 +659,7 @@ public class StratosApiV41Utils {
 
         return PojoConverter.populatePartitionGroupPojos(partitionGroups);
     }
-    
+
     // Util methods for services and subscriptions
 
     public static List<Cartridge> getSubscriptions(String cartridgeSearchString, String serviceGroup, ConfigurationContext configurationContext) throws RestAPIException {
@@ -756,7 +738,7 @@ public class StratosApiV41Utils {
 
         return cartridges;
     }
-    
+
     private static Cartridge getCartridgeFromSubscription(CartridgeSubscription subscription) throws RestAPIException {
 
         if (subscription == null) {
@@ -824,9 +806,9 @@ public class StratosApiV41Utils {
     public static CartridgeSubscription getCartridgeSubscription(String alias, ConfigurationContext configurationContext) {
         return CartridgeSubscriptionManager.getCartridgeSubscription(ApplicationManagementUtil.getTenantId(configurationContext), alias);
     }
-       
+
     // Util methods for clusters
-    
+
     public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenant(ConfigurationContext configurationContext) {
 
         Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
@@ -887,7 +869,7 @@ public class StratosApiV41Utils {
     }
 
     // Util methods for service groups
-    
+
     public static void createServiceGroupDefinition(ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException {
 
         try {
@@ -944,27 +926,29 @@ public class StratosApiV41Utils {
 
     // Util methods for Applications
 
-    public static void createApplicationDefinition(ApplicationDefinition appDefinition, ConfigurationContext ctxt,
+    /**
+     * Verify the existence of the application and add it.
+     * @param appDefinition
+     * @param ctxt
+     * @param userName
+     * @param tenantDomain
+     * @throws RestAPIException
+     */
+    public static void addApplication(ApplicationDefinition appDefinition, ConfigurationContext ctxt,
                                                    String userName, String tenantDomain)
             throws RestAPIException {
 
         // check if an application with same id already exists
-        // check if application with same appId / tenant already exists
-        CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager();
-        int tenantId = ApplicationManagementUtil.getTenantId(ctxt);
-        String appId = appDefinition.getApplicationId();
-
         try {
-            if (subscriptionMgr.getApplicationSubscription(appId, tenantId) != null) {
-                String msg = "Duplicate application appId: " + appId + " for tenant " + tenantId;
+            if (AutoscalerServiceClient.getServiceClient().getApplication(appDefinition.getApplicationId()) != null) {
+                String msg = "Application already exists: [application-id]" + appDefinition.getApplicationId();
                 throw new RestAPIException(msg);
             }
-        } catch (ApplicationSubscriptionException e1) {
-            throw new RestAPIException(e1);
+        } catch (RemoteException e) {
+            throw new RestAPIException("Could not read application", e);
         }
 
-        ApplicationContext applicationContext =
-                PojoConverter.convertApplicationBeanToApplicationContext(appDefinition);
+        ApplicationContext applicationContext = PojoConverter.convertApplicationDefinitionToApplicationContext(appDefinition);
         applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
         applicationContext.setTenantDomain(tenantDomain);
         applicationContext.setTeantAdminUsername(userName);
@@ -981,7 +965,7 @@ public class StratosApiV41Utils {
         }
 
         try {
-            AutoscalerServiceClient.getServiceClient().deployApplication(applicationContext);
+            AutoscalerServiceClient.getServiceClient().addApplication(applicationContext);
         } catch (AutoScalerServiceApplicationDefinitionExceptionException e) {
             throw new RestAPIException(e);
         } catch (RemoteException e) {
@@ -991,38 +975,60 @@ public class StratosApiV41Utils {
 
     /**
      * Deploy application with a deployment policy.
-     * @param deploymentPolicyBean
+     *
+     * @param applicationId
+     * @param deploymentPolicy
      * @throws RestAPIException
      */
     public static void deployApplication(
-            org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy deploymentPolicyBean)
+            String applicationId,
+            org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy deploymentPolicy)
             throws RestAPIException {
 
-        if (log.isInfoEnabled()) {
-            log.info(String.format("Starting to deploy application: [application-id] %s",
-                    deploymentPolicyBean.getApplicationId()));
-        }
+        try {
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Starting to deploy application: [application-id] %s", applicationId));
+            }
 
-        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
-        if (autoscalerServiceClient != null) {
+            AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+            ApplicationContext application = autoscalerServiceClient.getApplication(applicationId);
+            if(application == null) {
+                String message = String.format("Application is not found: [application-id] %s", applicationId);
+                log.error(message);
+                throw new RestAPIException(message);
+            }
+            if ((application != null) && (application.getStatus().equals(APPLICATION_STATUS_DEPLOYED))) {
+                String message = String.format("Application is already deployed: [application-id] %s", applicationId);
+                log.error(message);
+                throw new RestAPIException(message);
+            }
 
-            org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy deploymentPolicy =
-                    PojoConverter.convetToASDeploymentPolicyPojo(deploymentPolicyBean);
+            if (!applicationId.equals(deploymentPolicy.getApplicationPolicy().getApplicationId())) {
+                String message = String.format("Application id %s does not match with the deployment policy",
+                        applicationId);
+                log.error(message);
+                throw new RestAPIException(message);
+            }
 
-            try {
-                autoscalerServiceClient.deployDeploymentPolicy(deploymentPolicy);
-                if(log.isInfoEnabled()) {
-                    log.info(String.format("Application deployed successfully: [application-id] %s [deployment-policy-id] %s",
-                            deploymentPolicy.getApplicationId(), deploymentPolicy.getApplicationId()));
-                }
-            } catch (RemoteException e) {
-                log.error(e.getMessage(), e);
-                throw new RestAPIException(e.getMessage(), e);
-            } catch (AutoScalerServiceInvalidPolicyExceptionException e) {
-                String message = e.getFaultMessage().getInvalidPolicyException().getMessage();
-                log.error(message, e);
-                throw new RestAPIException(message, e);
+            org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy stubDeploymentPolicy =
+                    PojoConverter.convetToASDeploymentPolicyPojo(deploymentPolicy);
+
+            autoscalerServiceClient.deployApplication(applicationId, stubDeploymentPolicy);
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Application deployed successfully: [application-id] %s [deployment-policy-id] %s",
+                        stubDeploymentPolicy.getApplicationId(), stubDeploymentPolicy.getId()));
             }
+        } catch (RemoteException e) {
+            log.error(e.getMessage(), e);
+            throw new RestAPIException(e.getMessage(), e);
+        } catch (AutoScalerServiceInvalidPolicyExceptionException e) {
+            String message = e.getFaultMessage().getInvalidPolicyException().getMessage();
+            log.error(message, e);
+            throw new RestAPIException(message, e);
+        } catch (AutoScalerServiceApplicationDefinitionExceptionException e) {
+            String message = e.getMessage();
+            log.error(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
@@ -1035,34 +1041,62 @@ public class StratosApiV41Utils {
         }
     }
 
-    public static void removeApplicationDefinition(String appId, ConfigurationContext ctxt,
-                                         String userName, String tenantDomain) throws RestAPIException {
+    public static void deleteApplication(String applicationId) throws RestAPIException {
 
         try {
-            int tenantId = ApplicationManagementUtil.getTenantId(ctxt);
-            AutoscalerServiceClient.getServiceClient().undeployApplication(appId, tenantId, tenantDomain);
+            AutoscalerServiceClient.getServiceClient().deleteApplication(applicationId);
+        } catch (RemoteException e) {
+            String message = "Could not delete application: [application-id] " + applicationId;
+            log.error(message, e);
+            throw new RestAPIException(message, e);
+        }
+    }
 
+    public static ApplicationDefinition getApplication(String applicationId) throws RestAPIException {
+        try {
+            return PojoConverter.convertApplicationContextToApplicationDefinition(
+                    AutoscalerServiceClient.getServiceClient().getApplication(applicationId));
         } catch (RemoteException e) {
-            throw new RestAPIException(e);
-        } catch (AutoScalerServiceApplicationDefinitionExceptionException e) {
-            throw new RestAPIException(e);
+            String message = "Could not read application: [application-id] " + applicationId;
+            log.error(message, e);
+            throw new RestAPIException(message, e);
         }
+    }
 
+    public static List<ApplicationDefinition> getApplications() throws RestAPIException {
+        try {
+            List<ApplicationDefinition> applicationDefinitions = new ArrayList<ApplicationDefinition>();
+            ApplicationContext[] applicationContexts = AutoscalerServiceClient.getServiceClient().getApplications();
+            for(ApplicationContext applicationContext : applicationContexts) {
+                ApplicationDefinition applicationDefinition =
+                        PojoConverter.convertApplicationContextToApplicationDefinition(applicationContext);
+            }
+            return applicationDefinitions;
+        } catch (RemoteException e) {
+            String message = "Could not read applications";
+            log.error(message, e);
+            throw new RestAPIException(message, e);
+        }
     }
 
     public static void undeployApplication(String applicationId) throws RestAPIException {
         AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
         if (autoscalerServiceClient != null) {
             try {
-                autoscalerServiceClient.unDeployDeploymentPolicy(applicationId);
+                autoscalerServiceClient.undeployApplication(applicationId);
             } catch (RemoteException e) {
-                log.error("Error while unDeploying the Deployment Policy for  " + applicationId);
-                throw new RestAPIException(e);
+                String message = "Could not undeploy application: [application-id] " + applicationId;
+                log.error(message, e);
+                throw new RestAPIException(message, e);
+            } catch (AutoScalerServiceApplicationDefinitionExceptionException e) {
+                String message = "Could not undeploy application: [application-id] " + applicationId;
+                log.error(message, e);
+                throw new RestAPIException(message, e);
             }
         }
     }
     
-    public static ApplicationBean[] getApplications() {
+    public static ApplicationBean[] getApplicationRuntimes() {
         List<ApplicationBean> applicationBeanList = new ArrayList<ApplicationBean>();
         try {
             ApplicationManager.acquireReadLockForApplications();
@@ -1080,7 +1114,7 @@ public class StratosApiV41Utils {
         return applicationBeanList.toArray(new ApplicationBean[applicationBeanList.size()]);
     }
 
-    public static ApplicationBean getApplication(String applicationId) {
+    public static ApplicationBean getApplicationRuntime(String applicationId) {
         ApplicationBean applicationBean = null;
         try {
             ApplicationManager.acquireReadLockForApplication(applicationId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/PojoConverter.java
index ec4ef53..6c45c58 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/PojoConverter.java
@@ -47,10 +47,7 @@ import org.apache.stratos.cloud.controller.stub.domain.ServiceGroup;
 import org.apache.stratos.cloud.controller.stub.domain.Volume;
 import org.apache.stratos.common.Properties;
 import org.apache.stratos.common.Property;
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
-import org.apache.stratos.manager.composite.application.beans.CartridgeDefinition;
-import org.apache.stratos.manager.composite.application.beans.GroupDefinition;
-import org.apache.stratos.manager.composite.application.beans.SubscribableInfo;
+import org.apache.stratos.manager.composite.application.beans.*;
 import org.apache.stratos.manager.deploy.service.Service;
 import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
 import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
@@ -1060,7 +1057,7 @@ public class PojoConverter {
         return portRangeBean;
     }
 
-    public static ApplicationContext convertApplicationBeanToApplicationContext(ApplicationDefinition compositeAppDefinition) {
+    public static ApplicationContext convertApplicationDefinitionToApplicationContext(ApplicationDefinition compositeAppDefinition) {
 
         org.apache.stratos.autoscaler.stub.pojo.ApplicationContext applicationContext =
                 new org.apache.stratos.autoscaler.stub.pojo.ApplicationContext();
@@ -1075,25 +1072,133 @@ public class PojoConverter {
                       
             // top level Groups
             if (compositeAppDefinition.getComponents().getGroups() != null) {
-                componentContext.setGroupContexts(getgroupContextArrayFromGroupDefinitions(compositeAppDefinition.getComponents().getGroups()));
+                componentContext.setGroupContexts(
+                        convertGroupDefinitionsToGroupContexts(compositeAppDefinition.getComponents().getGroups()));
             }
             // top level dependency information
             if (compositeAppDefinition.getComponents().getDependencies() != null) {
-                componentContext.setDependencyContext(getDependencyContextFromDependencyDefinition(compositeAppDefinition.getComponents().getDependencies()));
+                componentContext.setDependencyContext(
+                        convertDependencyDefinitionsToDependencyContexts(compositeAppDefinition.getComponents().getDependencies()));
             }
             // top level cartridge context information
             if (compositeAppDefinition.getComponents().getCartridges() != null) {
-                componentContext.setCartridgeContexts(getCartridgeContextArrayFromCartridgeDefinition(compositeAppDefinition.getComponents().getCartridges()));
+                componentContext.setCartridgeContexts(
+                        convertCartridgeDefinitionsToCartridgeContexts(compositeAppDefinition.getComponents().getCartridges()));
             }
-
             applicationContext.setComponents(componentContext);
         }
-
-        
         return applicationContext;
     }
 
-    private static CartridgeContext[] getCartridgeContextArrayFromCartridgeDefinition(
+    public static ApplicationDefinition convertApplicationContextToApplicationDefinition(ApplicationContext applicationContext) {
+        ApplicationDefinition applicationDefinition = new ApplicationDefinition();
+        applicationDefinition.setApplicationId(applicationContext.getApplicationId());
+        applicationDefinition.setAlias(applicationContext.getAlias());
+
+        // convert and set components
+        if (applicationContext.getComponents() != null) {
+            // top level Groups
+            if (applicationContext.getComponents().getGroupContexts() != null) {
+                applicationDefinition.getComponents().setGroups(
+                        convertGroupContextsToGroupDefinitions(applicationContext.getComponents().getGroupContexts()));
+            }
+            // top level dependency information
+            if (applicationContext.getComponents().getDependencyContext() != null) {
+                applicationDefinition.getComponents().setDependencies(
+                        convertDependencyContextsToDependencyDefinitions(applicationContext.getComponents().getDependencyContext()));
+            }
+            // top level cartridge context information
+            if (applicationContext.getComponents().getCartridgeContexts() != null) {
+                applicationDefinition.getComponents().setCartridges(
+                        convertCartridgeContextsToCartridgeDefinitions(applicationContext.getComponents().getCartridgeContexts()));
+            }
+        }
+        return applicationDefinition;
+    }
+
+    private static List<GroupDefinition> convertGroupContextsToGroupDefinitions(GroupContext[] groupContexts) {
+        List<GroupDefinition> groupDefinitions = new ArrayList<GroupDefinition>();
+        for(GroupContext groupContext : groupContexts) {
+            GroupDefinition groupDefinition = new GroupDefinition();
+            groupDefinition.setAlias(groupContext.getAlias());
+            groupDefinition.setGroupMaxInstances(groupContext.getGroupMaxInstances());
+            groupDefinition.setGroupMinInstances(groupContext.getGroupMinInstances());
+            groupDefinition.setGroupScalingEnabled(groupContext.getGroupScalingEnabled());
+            groupDefinition.setName(groupContext.getName());
+            groupDefinition.setGroups(convertGroupContextsToGroupDefinitions(groupContext.getGroupContexts()));
+            groupDefinition.setCartridges(convertCartridgeContextsToCartridgeDefinitions(
+                    groupContext.getCartridgeContexts()));
+            groupDefinitions.add(groupDefinition);
+        }
+        return groupDefinitions;
+    }
+
+    private static DependencyDefinitions convertDependencyContextsToDependencyDefinitions(DependencyContext dependencyContext) {
+        DependencyDefinitions dependencyDefinitions = new DependencyDefinitions();
+        dependencyDefinitions.setTerminationBehaviour(dependencyContext.getTerminationBehaviour());
+
+            if(dependencyContext.getStartupOrdersContexts() != null) {
+                List<String> startupOrders = new ArrayList<String>();
+                for(String item : dependencyContext.getStartupOrdersContexts()) {
+                    startupOrders.add(item);
+                }
+                dependencyDefinitions.setStartupOrders(startupOrders);
+            }
+            if (dependencyContext.getScalingDependents() != null) {
+                List<String> scalingDependents = new ArrayList<String>();
+                for(String item : dependencyContext.getScalingDependents()) {
+                    scalingDependents.add(item);
+                }
+                dependencyDefinitions.setScalingDependants(scalingDependents);
+            }
+        return dependencyDefinitions;
+    }
+
+    private static List<CartridgeDefinition> convertCartridgeContextsToCartridgeDefinitions(CartridgeContext[] cartridgeContexts) {
+        List<CartridgeDefinition> cartridgeDefinitions = new ArrayList<CartridgeDefinition>();
+        for(CartridgeContext cartridgeContext : cartridgeContexts) {
+            CartridgeDefinition cartridgeDefinition = new CartridgeDefinition();
+            cartridgeDefinition.setType(cartridgeContext.getType());
+            cartridgeDefinition.setCartridgeMin(cartridgeContext.getCartridgeMin());
+            cartridgeDefinition.setCartridgeMax(cartridgeContext.getCartridgeMax());
+            cartridgeDefinition.setSubscribableInfo(convertSubscribableInfoContextToSubscribableInfo(cartridgeContext.getSubscribableInfoContext()));
+            cartridgeDefinitions.add(cartridgeDefinition);
+        }
+        return cartridgeDefinitions;
+    }
+
+    private static SubscribableInfo convertSubscribableInfoContextToSubscribableInfo(
+            SubscribableInfoContext subscribableInfoContext) {
+        SubscribableInfo subscribableInfo = new SubscribableInfo();
+        subscribableInfo.setAlias(subscribableInfoContext.getAlias());
+        subscribableInfo.setAutoscalingPolicy(subscribableInfoContext.getAutoscalingPolicy());
+        subscribableInfo.setDependencyAliases(subscribableInfoContext.getDependencyAliases());
+        subscribableInfo.setDeploymentPolicy(subscribableInfoContext.getDeploymentPolicy());
+        subscribableInfo.setMinMembers(subscribableInfoContext.getMinMembers());
+        subscribableInfo.setMaxMembers(subscribableInfoContext.getMaxMembers());
+        subscribableInfo.setPrivateRepo(subscribableInfoContext.getPrivateRepo());
+        subscribableInfo.setProperty(convertPropertiesToPropertyBeansList(subscribableInfoContext.getProperties()));
+        subscribableInfo.setRepoPassword(subscribableInfoContext.getRepoPassword());
+        subscribableInfo.setRepoUsername(subscribableInfoContext.getRepoUsername());
+        subscribableInfo.setRepoUrl(subscribableInfoContext.getRepoUrl());
+        return subscribableInfo;
+    }
+
+    private static List<org.apache.stratos.manager.composite.application.beans.PropertyBean>
+    convertPropertiesToPropertyBeansList(org.apache.stratos.autoscaler.stub.Properties properties) {
+        List<org.apache.stratos.manager.composite.application.beans.PropertyBean> propertyBeanList =
+                new ArrayList<org.apache.stratos.manager.composite.application.beans.PropertyBean>();
+        for(org.apache.stratos.autoscaler.stub.Property property : properties.getProperties()) {
+            org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean =
+                    new org.apache.stratos.manager.composite.application.beans.PropertyBean();
+            propertyBean.setName(property.getName());
+            propertyBean.setValue(property.getValue());
+            propertyBeanList.add(propertyBean);
+        }
+        return propertyBeanList;
+    }
+
+    private static CartridgeContext[] convertCartridgeDefinitionsToCartridgeContexts(
             List<CartridgeDefinition> cartridges) {
 
     	CartridgeContext[] cartridgeContextArray = new CartridgeContext[cartridges.size()];
@@ -1143,13 +1248,11 @@ public class PojoConverter {
     }
 
 	
-    private static DependencyContext getDependencyContextFromDependencyDefinition(DependencyDefinitions dependencyDefinitions) {
-
+    private static DependencyContext convertDependencyDefinitionsToDependencyContexts(DependencyDefinitions dependencyDefinitions) {
         DependencyContext dependencyContext = new DependencyContext();
         dependencyContext.setTerminationBehaviour(dependencyDefinitions.getTerminationBehaviour());
 
         if (dependencyDefinitions != null){
-
             if(dependencyDefinitions.getStartupOrders() != null) {
                 String[] startupOrders = new String[dependencyDefinitions.getStartupOrders().size()];
                 startupOrders = dependencyDefinitions.getStartupOrders().toArray(startupOrders);
@@ -1161,14 +1264,11 @@ public class PojoConverter {
                 dependencyContext.setScalingDependents(scalingDependents);
             }
         }
-
-
-
         return dependencyContext;
     }
 
     private static org.apache.stratos.autoscaler.stub.pojo.GroupContext[]
-    getgroupContextArrayFromGroupDefinitions(List<GroupDefinition> groupDefinitions) {
+    convertGroupDefinitionsToGroupContexts(List<GroupDefinition> groupDefinitions) {
 
         GroupContext[] groupContexts = new GroupContext[groupDefinitions.size()];
         int i = 0;
@@ -1182,10 +1282,10 @@ public class PojoConverter {
            
             // Groups
             if (groupDefinition.getGroups() != null) {
-                groupContext.setGroupContexts(getgroupContextArrayFromGroupDefinitions(groupDefinition.getGroups()));
+                groupContext.setGroupContexts(convertGroupDefinitionsToGroupContexts(groupDefinition.getGroups()));
             }
             
-            groupContext.setCartridgeContexts(getCartridgeContextArrayFromCartridgeDefinition(groupDefinition.getCartridges()));
+            groupContext.setCartridgeContexts(convertCartridgeDefinitionsToCartridgeContexts(groupDefinition.getCartridges()));
             groupContexts[i++] = groupContext;
         }
 
@@ -1200,6 +1300,8 @@ public class PojoConverter {
 
         ApplicationBean applicationBean = new ApplicationBean();
         applicationBean.setId(application.getUniqueIdentifier());
+        applicationBean.setName(application.getName());
+        applicationBean.setDescription(application.getDescription());
         applicationBean.setTenantDomain(application.getTenantDomain());
         applicationBean.setTenantAdminUsername(application.getTenantAdminUserName());
         applicationBean.setInstances(setApplicationInstances(application));


[2/4] stratos git commit: Refining application deployment process

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
index d9bd27a..58949c3 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
@@ -1,506 +1,463 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax27="http://common.stratos.apache.org/xsd" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax25="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax23="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax216="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax218="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax221="http://kubernetes.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax223="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax211="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:http="http://sc
 hemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.apache.org">
-    <wsdl:documentation>AutoScalerService</wsdl:documentation>
+<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax27="http://common.stratos.apache.org/xsd" xmlns:ax25="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax23="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax21="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax214="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax220="http://kubernetes.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax222="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/a
 ddressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.apache.org">
     <wsdl:types>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="AutoscalePolicy">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="instanceRoundingFactor" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax214:LoadThresholds"></xs:element>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="instanceRoundingFactor" type="xs:float"/>
+                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax21:LoadThresholds"/>
+                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax214:LoadAverageThresholds"></xs:element>
-                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax214:MemoryConsumptionThresholds"></xs:element>
-                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax214:RequestsInFlightThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax21:LoadAverageThresholds"/>
+                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax21:MemoryConsumptionThresholds"/>
+                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax21:RequestsInFlightThresholds"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadAverageThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="MemoryConsumptionThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="RequestsInFlightThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax224="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
+        <xs:schema xmlns:ax215="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://common.stratos.apache.org/xsd"/>
             <xs:complexType name="ApplicationContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="components" nillable="true" type="ax223:ComponentContext"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="teantAdminUsername" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="components" nillable="true" type="ax214:ComponentContext"/>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"/>
+                    <xs:element minOccurs="0" name="status" nillable="true" type="ax214:ApplicationContextStatus"/>
+                    <xs:element minOccurs="0" name="teantAdminUsername" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ComponentContext">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax223:CartridgeContext"></xs:element>
-                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax223:DependencyContext"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax223:GroupContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax214:CartridgeContext"/>
+                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax214:DependencyContext"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax214:GroupContext"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="CartridgeContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="cartridgeMax" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="cartridgeMin" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax223:SubscribableInfoContext"></xs:element>
-                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="cartridgeMax" type="xs:int"/>
+                    <xs:element minOccurs="0" name="cartridgeMin" type="xs:int"/>
+                    <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax214:SubscribableInfoContext"/>
+                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="SubscribableInfoContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="maxMembers" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="minMembers" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="privateRepo" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="repoPassword" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="repoUrl" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="repoUsername" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="maxMembers" type="xs:int"/>
+                    <xs:element minOccurs="0" name="minMembers" type="xs:int"/>
+                    <xs:element minOccurs="0" name="privateRepo" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"/>
+                    <xs:element minOccurs="0" name="repoPassword" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="repoUrl" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="repoUsername" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="DependencyContext">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependents" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrdersContexts" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependents" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrdersContexts" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="GroupContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax223:CartridgeContext"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax223:GroupContext"></xs:element>
-                    <xs:element minOccurs="0" name="groupMaxInstances" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="groupMinInstances" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="groupScalingEnabled" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax214:CartridgeContext"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax214:GroupContext"/>
+                    <xs:element minOccurs="0" name="groupMaxInstances" type="xs:int"/>
+                    <xs:element minOccurs="0" name="groupMinInstances" type="xs:int"/>
+                    <xs:element minOccurs="0" name="groupScalingEnabled" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
+            <xs:complexType name="ApplicationContextStatus">
+                <xs:complexContent>
+                    <xs:extension base="xs:Enum">
+                        <xs:sequence/>
+                    </xs:extension>
+                </xs:complexContent>
+            </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="ServiceGroup">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax218:Dependencies"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax218:ServiceGroup"></xs:element>
-                    <xs:element minOccurs="0" name="groupscalingEnabled" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax222:Dependencies"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax222:ServiceGroup"/>
+                    <xs:element minOccurs="0" name="groupscalingEnabled" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Dependencies">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependants" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependants" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema xmlns:ax29="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
             <xs:complexType name="DeploymentPolicy">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax29:Partition"></xs:element>
-                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationLevelNetworkPartitions" nillable="true" type="ax29:ApplicationLevelNetworkPartition"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childLevelNetworkPartitions" nillable="true" type="ax29:ChildLevelNetworkPartition"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childPolicies" nillable="true" type="ax25:ChildPolicy"></xs:element>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax29:Partition"/>
+                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationLevelNetworkPartitions" nillable="true" type="ax29:ApplicationLevelNetworkPartition"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childLevelNetworkPartitions" nillable="true" type="ax29:ChildLevelNetworkPartition"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childPolicies" nillable="true" type="ax25:ChildPolicy"/>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ChildPolicy">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childLevelNetworkPartitions" nillable="true" type="ax29:ChildLevelNetworkPartition"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childLevelNetworkPartitions" nillable="true" type="ax29:ChildLevelNetworkPartition"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://application.exception.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="ApplicationDefinitionException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema xmlns:ax28="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://common.stratos.apache.org/xsd"/>
             <xs:complexType name="Partition">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"/>
+                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ApplicationLevelNetworkPartition">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="activeByDefault" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax26:Partition"></xs:element>
+                    <xs:element minOccurs="0" name="activeByDefault" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax26:Partition"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ChildLevelNetworkPartition">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childLevelPartitions" nillable="true" type="ax26:ChildLevelPartition"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="min" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="childLevelPartitions" nillable="true" type="ax26:ChildLevelPartition"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="min" type="xs:int"/>
+                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ChildLevelPartition">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="max" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="partitionId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="max" type="xs:int"/>
+                    <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="partitionId" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://kubernetes.exception.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="InvalidServiceGroupException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://common.stratos.apache.org/xsd">
             <xs:complexType name="Properties">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax27:Property"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax27:Property"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Property">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax215="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax220="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://common.stratos.apache.org/xsd" xmlns:ax222="http://kubernetes.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax210="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax225="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
-            <xs:import namespace="http://policy.exception.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://kubernetes.exception.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:element name="AutoScalerServiceInvalidPolicyException">
+        <xs:schema xmlns:ax24="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax216="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax22="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://common.stratos.apache.org/xsd" xmlns:ax218="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax221="http://kubernetes.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax223="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax210="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax211="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
+            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://policy.exception.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://network.partition.deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://common.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://kubernetes.exception.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"/>
+            <xs:element name="getAutoScalingPolicies">
                 <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax23:InvalidPolicyException"></xs:element>
-                    </xs:sequence>
+                    <xs:sequence/>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="updateDeploymentPolicy">
+            <xs:element name="getAutoScalingPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax21:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="updateDeploymentPolicyResponse">
+            <xs:element name="AutoScalerServiceInvalidPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax23:InvalidPolicyException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoScalerServiceInvalidArgumentException">
+            <xs:element name="addAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax212:InvalidArgumentException"></xs:element>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax21:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="updateClusterMonitor">
+            <xs:element name="addAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="updateAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax214:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax21:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="updateAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoScalerServiceAutoScalerException">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax212:AutoScalerException"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="undeployServiceGroup">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="undeployDeploymentPolicy">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="undeployDeploymentPolicyResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="AutoScalerServiceApplicationDefinitionException">
+            <xs:element name="getDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax217:ApplicationDefinitionException"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="unDeployApplicationDefinition">
+            <xs:element name="getDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
-                        <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax25:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="serviceGroupExist">
+            <xs:element name="getAutoscalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="serviceGroupExistResponse">
+            <xs:element name="getAutoscalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax21:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getValidDeploymentPoliciesforCartridge">
+            <xs:element name="getNetworkPartitions">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getValidDeploymentPoliciesforCartridgeResponse">
+            <xs:element name="getNetworkPartitionsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:ApplicationLevelNetworkPartition"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroups">
-                <xs:complexType>
-                    <xs:sequence></xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getServiceGroupsResponse">
+            <xs:element name="AutoScalerServiceApplicationDefinitionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax219:ServiceGroup"></xs:element>
+                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax212:ApplicationDefinitionException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroup">
+            <xs:element name="addApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax216:ApplicationContext"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroupResponse">
+            <xs:element name="getApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:ServiceGroup"></xs:element>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getPartitionsOfGroup">
+            <xs:element name="getApplicationResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="groupId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax216:ApplicationContext"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getPartitionsOfGroupResponse">
+            <xs:element name="getApplications">
                 <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:Partition"></xs:element>
-                    </xs:sequence>
+                    <xs:sequence/>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getNetworkPartitions">
+            <xs:element name="getApplicationsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax216:ApplicationContext"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getNetworkPartitionsResponse">
+            <xs:element name="deployApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:ApplicationLevelNetworkPartition"></xs:element>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="policy" nillable="true" type="ax25:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getDeploymentPolicy">
+            <xs:element name="deployApplicationResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getDeploymentPolicyResponse">
+            <xs:element name="undeployApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getAutoscalingPolicy">
+            <xs:element name="deleteApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getAutoscalingPolicyResponse">
+            <xs:element name="AutoScalerServiceInvalidArgumentException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax214:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax217:InvalidArgumentException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getAllDeploymentPolicies">
-                <xs:complexType>
-                    <xs:sequence></xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getAllDeploymentPoliciesResponse">
+            <xs:element name="updateClusterMonitor">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
+                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getAllAutoScalingPolicy">
-                <xs:complexType>
-                    <xs:sequence></xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getAllAutoScalingPolicyResponse">
+            <xs:element name="AutoScalerServiceInvalidServiceGroupException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax214:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax220:InvalidServiceGroupException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoScalerServiceInvalidServiceGroupException">
+            <xs:element name="deployServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax221:InvalidServiceGroupException"></xs:element>
+                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax222:ServiceGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployServiceGroup">
+            <xs:element name="getServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax219:ServiceGroup"></xs:element>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployDeploymentPolicy">
+            <xs:element name="getServiceGroupResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="policy" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax222:ServiceGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployDeploymentPolicyResponse">
+            <xs:element name="AutoScalerServiceAutoScalerException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax217:AutoScalerException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployApplicationDefinition">
+            <xs:element name="getServiceGroups">
                 <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax223:ApplicationContext"></xs:element>
-                    </xs:sequence>
+                    <xs:sequence/>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addDeploymentPolicy">
+            <xs:element name="getServiceGroupsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax222:ServiceGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addDeploymentPolicyResponse">
+            <xs:element name="serviceGroupExist">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addAutoScalingPolicy">
+            <xs:element name="serviceGroupExistResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax214:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addAutoScalingPolicyResponse">
+            <xs:element name="undeployServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -508,1214 +465,704 @@
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.exception.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="InvalidPolicyException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="InvalidArgumentException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="AutoScalerException">
                 <xs:complexContent>
                     <xs:extension base="xs:RuntimeException">
-                        <xs:sequence></xs:sequence>
+                        <xs:sequence/>
                     </xs:extension>
                 </xs:complexContent>
             </xs:complexType>
         </xs:schema>
     </wsdl:types>
-    <wsdl:message name="updateKubernetesMasterRequest"></wsdl:message>
-    <wsdl:message name="updateKubernetesMasterResponse"></wsdl:message>
-    <wsdl:message name="addKubernetesGroupRequest"></wsdl:message>
-    <wsdl:message name="addKubernetesGroupResponse"></wsdl:message>
+    <wsdl:message name="getAutoScalingPoliciesRequest">
+        <wsdl:part name="parameters" element="ns:getAutoScalingPolicies"/>
+    </wsdl:message>
+    <wsdl:message name="getAutoScalingPoliciesResponse">
+        <wsdl:part name="parameters" element="ns:getAutoScalingPoliciesResponse"/>
+    </wsdl:message>
     <wsdl:message name="getServiceGroupsRequest">
-        <wsdl:part name="parameters" element="ns:getServiceGroups"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getServiceGroups"/>
     </wsdl:message>
     <wsdl:message name="getServiceGroupsResponse">
-        <wsdl:part name="parameters" element="ns:getServiceGroupsResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getServiceGroupsResponse"/>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceAutoScalerException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceAutoScalerException"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceAutoScalerException"/>
+    </wsdl:message>
+    <wsdl:message name="getApplicationRequest">
+        <wsdl:part name="parameters" element="ns:getApplication"/>
     </wsdl:message>
-    <wsdl:message name="getPartitionsOfGroupRequest">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfGroup"></wsdl:part>
+    <wsdl:message name="getApplicationResponse">
+        <wsdl:part name="parameters" element="ns:getApplicationResponse"/>
     </wsdl:message>
-    <wsdl:message name="getPartitionsOfGroupResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfGroupResponse"></wsdl:part>
+    <wsdl:message name="deployApplicationRequest">
+        <wsdl:part name="parameters" element="ns:deployApplication"/>
     </wsdl:message>
-    <wsdl:message name="getAllAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicy"></wsdl:part>
+    <wsdl:message name="deployApplicationResponse">
+        <wsdl:part name="parameters" element="ns:deployApplicationResponse"/>
     </wsdl:message>
-    <wsdl:message name="getAllAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicyResponse"></wsdl:part>
+    <wsdl:message name="AutoScalerServiceApplicationDefinitionException">
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceApplicationDefinitionException"/>
     </wsdl:message>
     <wsdl:message name="getDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getDeploymentPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getDeploymentPolicy"/>
     </wsdl:message>
     <wsdl:message name="getDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getDeploymentPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getDeploymentPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="serviceGroupExistRequest">
-        <wsdl:part name="parameters" element="ns:serviceGroupExist"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:serviceGroupExist"/>
     </wsdl:message>
     <wsdl:message name="serviceGroupExistResponse">
-        <wsdl:part name="parameters" element="ns:serviceGroupExistResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:serviceGroupExistResponse"/>
     </wsdl:message>
-    <wsdl:message name="getMasterForKubernetesGroupRequest"></wsdl:message>
-    <wsdl:message name="getMasterForKubernetesGroupResponse"></wsdl:message>
     <wsdl:message name="addAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"/>
     </wsdl:message>
     <wsdl:message name="addAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidPolicyException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPolicyException"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="unDeployApplicationDefinitionRequest">
-        <wsdl:part name="parameters" element="ns:unDeployApplicationDefinition"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="AutoScalerServiceApplicationDefinitionException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceApplicationDefinitionException"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPolicyException"/>
     </wsdl:message>
     <wsdl:message name="getServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:getServiceGroup"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getServiceGroup"/>
     </wsdl:message>
     <wsdl:message name="getServiceGroupResponse">
-        <wsdl:part name="parameters" element="ns:getServiceGroupResponse"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="removeKubernetesGroupRequest"></wsdl:message>
-    <wsdl:message name="removeKubernetesGroupResponse"></wsdl:message>
-    <wsdl:message name="getAllDeploymentPoliciesRequest">
-        <wsdl:part name="parameters" element="ns:getAllDeploymentPolicies"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="getAllDeploymentPoliciesResponse">
-        <wsdl:part name="parameters" element="ns:getAllDeploymentPoliciesResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getServiceGroupResponse"/>
     </wsdl:message>
-    <wsdl:message name="getValidDeploymentPoliciesforCartridgeRequest">
-        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridge"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="getValidDeploymentPoliciesforCartridgeResponse">
-        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridgeResponse"></wsdl:part>
+    <wsdl:message name="deleteApplicationRequest">
+        <wsdl:part name="parameters" element="ns:deleteApplication"/>
     </wsdl:message>
     <wsdl:message name="undeployServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:undeployServiceGroup"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="addKubernetesHostRequest"></wsdl:message>
-    <wsdl:message name="addKubernetesHostResponse"></wsdl:message>
-    <wsdl:message name="getAllAvailablePartitionsRequest"></wsdl:message>
-    <wsdl:message name="getAllAvailablePartitionsResponse"></wsdl:message>
-    <wsdl:message name="deployApplicationDefinitionRequest">
-        <wsdl:part name="parameters" element="ns:deployApplicationDefinition"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:undeployServiceGroup"/>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"/>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="deployDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:deployDeploymentPolicy"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="deployDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:deployDeploymentPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="updateAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicy"/>
     </wsdl:message>
     <wsdl:message name="updateAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicyResponse"/>
+    </wsdl:message>
+    <wsdl:message name="getApplicationsRequest">
+        <wsdl:part name="parameters" element="ns:getApplications"/>
     </wsdl:message>
-    <wsdl:message name="removeKubernetesHostRequest"></wsdl:message>
-    <wsdl:message name="removeKubernetesHostResponse"></wsdl:message>
-    <wsdl:message name="addPartitionRequest"></wsdl:message>
-    <wsdl:message name="addPartitionResponse"></wsdl:message>
-    <wsdl:message name="addDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:addDeploymentPolicy"></wsdl:part>
+    <wsdl:message name="getApplicationsResponse">
+        <wsdl:part name="parameters" element="ns:getApplicationsResponse"/>
     </wsdl:message>
-    <wsdl:message name="addDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:addDeploymentPolicyResponse"></wsdl:part>
+    <wsdl:message name="addApplicationRequest">
+        <wsdl:part name="parameters" element="ns:addApplication"/>
     </wsdl:message>
     <wsdl:message name="updateClusterMonitorRequest">
-        <wsdl:part name="parameters" element="ns:updateClusterMonitor"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:updateClusterMonitor"/>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidArgumentException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidArgumentException"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="getAllKubernetesGroupsRequest"></wsdl:message>
-    <wsdl:message name="getAllKubernetesGroupsResponse"></wsdl:message>
-    <wsdl:message name="updateDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:updateDeploymentPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidArgumentException"/>
     </wsdl:message>
-    <wsdl:message name="updateDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:updateDeploymentPolicyResponse"></wsdl:part>
+    <wsdl:message name="undeployApplicationRequest">
+        <wsdl:part name="parameters" element="ns:undeployApplication"/>
     </wsdl:message>
     <wsdl:message name="deployServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:deployServiceGroup"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:deployServiceGroup"/>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidServiceGroupException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidServiceGroupException"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidServiceGroupException"/>
     </wsdl:message>
-    <wsdl:message name="updateKubernetesHostRequest"></wsdl:message>
-    <wsdl:message name="updateKubernetesHostResponse"></wsdl:message>
-    <wsdl:message name="getHostsForKubernetesGroupRequest"></wsdl:message>
-    <wsdl:message name="getHostsForKubernetesGroupResponse"></wsdl:message>
     <wsdl:message name="getNetworkPartitionsRequest">
-        <wsdl:part name="parameters" element="ns:getNetworkPartitions"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getNetworkPartitions"/>
     </wsdl:message>
     <wsdl:message name="getNetworkPartitionsResponse">
-        <wsdl:part name="parameters" element="ns:getNetworkPartitionsResponse"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="undeployDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:undeployDeploymentPolicy"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="undeployDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:undeployDeploymentPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getNetworkPartitionsResponse"/>
     </wsdl:message>
     <wsdl:portType name="AutoScalerServicePortType">
-        <wsdl:operation name="updateKubernetesMaster">
-            <wsdl:input message="ns:updateKubernetesMasterRequest" wsaw:Action="urn:updateKubernetesMaster"></wsdl:input>
-            <wsdl:output message="ns:updateKubernetesMasterResponse" wsaw:Action="urn:updateKubernetesMasterResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="addKubernetesGroup">
-            <wsdl:input message="ns:addKubernetesGroupRequest" wsaw:Action="urn:addKubernetesGroup"></wsdl:input>
-            <wsdl:output message="ns:addKubernetesGroupResponse" wsaw:Action="urn:addKubernetesGroupResponse"></wsdl:output>
+        <wsdl:operation name="getAutoScalingPolicies">
+            <wsdl:input message="ns:getAutoScalingPoliciesRequest" wsaw:Action="urn:getAutoScalingPolicies"/>
+            <wsdl:output message="ns:getAutoScalingPoliciesResponse" wsaw:Action="urn:getAutoScalingPoliciesResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
-            <wsdl:input message="ns:getServiceGroupsRequest" wsaw:Action="urn:getServiceGroups"></wsdl:input>
-            <wsdl:output message="ns:getServiceGroupsResponse" wsaw:Action="urn:getServiceGroupsResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceAutoScalerException" name="AutoScalerServiceAutoScalerException" wsaw:Action="urn:getServiceGroupsAutoScalerServiceAutoScalerException"></wsdl:fault>
+            <wsdl:input message="ns:getServiceGroupsRequest" wsaw:Action="urn:getServiceGroups"/>
+            <wsdl:output message="ns:getServiceGroupsResponse" wsaw:Action="urn:getServiceGroupsResponse"/>
+            <wsdl:fault message="ns:AutoScalerServiceAutoScalerException" name="AutoScalerServiceAutoScalerException" wsaw:Action="urn:getServiceGroupsAutoScalerServiceAutoScalerException"/>
         </wsdl:operation>
-        <wsdl:operation name="getPartitionsOfGroup">
-            <wsdl:input message="ns:getPartitionsOfGroupRequest" wsaw:Action="urn:getPartitionsOfGroup"></wsdl:input>
-            <wsdl:output message="ns:getPartitionsOfGroupResponse" wsaw:Action="urn:getPartitionsOfGroupResponse"></wsdl:output>
+        <wsdl:operation name="getApplication">
+            <wsdl:input message="ns:getApplicationRequest" wsaw:Action="urn:getApplication"/>
+            <wsdl:output message="ns:getApplicationResponse" wsaw:Action="urn:getApplicationResponse"/>
         </wsdl:operation>
-        <wsdl:operation name="getAllAutoScalingPolicy">
-            <wsdl:input message="ns:getAllAutoScalingPolicyRequest" wsaw:Action="urn:getAllAutoScalingPolicy"></wsdl:input>
-            <wsdl:output message="ns:getAllAutoScalingPolicyResponse" wsaw:Action="urn:getAllAutoScalingPolicyResponse"></wsdl:output>
+        <wsdl:operation name="deployApplication">
+            <wsdl:input message="ns:deployApplicationRequest" wsaw:Action="urn:deployApplication"/>
+            <wsdl:output message="ns:deployApplicationResponse" wsaw:Action="urn:deployApplicationResponse"/>
+            <wsdl:fault message="ns:AutoScalerServiceApplicationDefinitionException" name="AutoScalerServiceApplicationDefinitionException" wsaw:Action="urn:deployApplicationAutoScalerServiceApplicationDefinitionException"/>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <wsdl:input message="ns:getDeploymentPolicyRequest" wsaw:Action="urn:getDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:getDeploymentPolicyResponse" wsaw:Action="urn:getDeploymentPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:getDeploymentPolicyRequest" wsaw:Action="urn:getDeploymentPolicy"/>
+            <wsdl:output message="ns:getDeploymentPolicyResponse" wsaw:Action="urn:getDeploymentPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="serviceGroupExist">
-            <wsdl:input message="ns:serviceGroupExistRequest" wsaw:Action="urn:serviceGroupExist"></wsdl:input>
-            <wsdl:output message="ns:serviceGroupExistResponse" wsaw:Action="urn:serviceGroupExistResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="getMasterForKubernetesGroup">
-            <wsdl:input message="ns:getMasterForKubernetesGroupRequest" wsaw:Action="urn:getMasterForKubernetesGroup"></wsdl:input>
-            <wsdl:output message="ns:getMasterForKubernetesGroupResponse" wsaw:Action="urn:getMasterForKubernetesGroupResponse"></wsdl:output>
+            <wsdl:input message="ns:serviceGroupExistRequest" wsaw:Action="urn:serviceGroupExist"/>
+            <wsdl:output message="ns:serviceGroupExistResponse" wsaw:Action="urn:serviceGroupExistResponse"/>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"></wsdl:input>
-            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="unDeployApplicationDefinition">
-            <wsdl:input message="ns:unDeployApplicationDefinitionRequest" wsaw:Action="urn:unDeployApplicationDefinition"></wsdl:input>
-            <wsdl:fault message="ns:AutoScalerServiceApplicationDefinitionException" name="AutoScalerServiceApplicationDefinitionException" wsaw:Action="urn:unDeployApplicationDefinitionAutoScalerServiceApplicationDefinitionException"></wsdl:fault>
+            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"/>
+            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoScalerServiceInvalidPolicyException"/>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
-            <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"></wsdl:input>
-            <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"></wsdl:output>
+            <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"/>
+            <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"/>
         </wsdl:operation>
-        <wsdl:operation name="removeKubernetesGroup">
-            <wsdl:input message="ns:removeKubernetesGroupRequest" wsaw:Action="urn:removeKubernetesGroup"></wsdl:input>
-            <wsdl:output message="ns:removeKubernetesGroupResponse" wsaw:Action="urn:removeKubernetesGroupResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="getAllDeploymentPolicies">
-            <wsdl:input message="ns:getAllDeploymentPoliciesRequest" wsaw:Action="urn:getAllDeploymentPolicies"></wsdl:input>
-            <wsdl:output message="ns:getAllDeploymentPoliciesResponse" wsaw:Action="urn:getAllDeploymentPoliciesResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="getValidDeploymentPoliciesforCartridge">
-            <wsdl:input message="ns:getValidDeploymentPoliciesforCartridgeRequest" wsaw:Action="urn:getValidDeploymentPoliciesforCartridge"></wsdl:input>
-            <wsdl:output message="ns:getValidDeploymentPoliciesforCartridgeResponse" wsaw:Action="urn:getValidDeploymentPoliciesforCartridgeResponse"></wsdl:output>
+        <wsdl:operation name="deleteApplication">
+            <wsdl:input message="ns:deleteApplicationRequest" wsaw:Action="urn:deleteApplication"/>
         </wsdl:operation>
         <wsdl:operation name="undeployServiceGroup">
-            <wsdl:input message="ns:undeployServiceGroupRequest" wsaw:Action="urn:undeployServiceGroup"></wsdl:input>
-            <wsdl:fault message="ns:AutoScalerServiceAutoScalerException" name="AutoScalerServiceAutoScalerException" wsaw:Action="urn:undeployServiceGroupAutoScalerServiceAutoScalerException"></wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="addKubernetesHost">
-            <wsdl:input message="ns:addKubernetesHostRequest" wsaw:Action="urn:addKubernetesHost"></wsdl:input>
-            <wsdl:output message="ns:addKubernetesHostResponse" wsaw:Action="urn:addKubernetesHostResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="getAllAvailablePartitions">
-            <wsdl:input message="ns:getAllAvailablePartitionsRequest" wsaw:Action="urn:getAllAvailablePartitions"></wsdl:input>
-            <wsdl:output message="ns:getAllAvailablePartitionsResponse" wsaw:Action="urn:getAllAvailablePartitionsResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="deployApplicationDefinition">
-            <wsdl:input message="ns:deployApplicationDefinitionRequest" wsaw:Action="urn:deployApplicationDefinition"></wsdl:input>
-            <wsdl:fault message="ns:AutoScalerServiceApplicationDefinitionException" name="AutoScalerServiceApplicationDefinitionException" wsaw:Action="urn:deployApplicationDefinitionAutoScalerServiceApplicationDefinitionException"></wsdl:fault>
+            <wsdl:input message="ns:undeployServiceGroupRequest" wsaw:Action="urn:undeployServiceGroup"/>
+            <wsdl:fault message="ns:AutoScalerServiceAutoScalerException" name="AutoScalerServiceAutoScalerException" wsaw:Action="urn:undeployServiceGroupAutoScalerServiceAutoScalerException"/>
         </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
-            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"></wsdl:input>
-            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="deployDeploymentPolicy">
-            <wsdl:input message="ns:deployDeploymentPolicyRequest" wsaw:Action="urn:deployDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:deployDeploymentPolicyResponse" wsaw:Action="urn:deployDeploymentPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"/>
+            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="updateAutoScalingPolicy">
-            <wsdl:input message="ns:updateAutoScalingPolicyRequest" wsaw:Action="urn:updateAutoScalingPolicy"></wsdl:input>
-            <wsdl:output message="ns:updateAutoScalingPolicyResponse" wsaw:Action="urn:updateAutoScalingPolicyResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:updateAutoScalingPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
+            <wsdl:input message="ns:updateAutoScalingPolicyRequest" wsaw:Action="urn:updateAutoScalingPolicy"/>
+            <wsdl:output message="ns:updateAutoScalingPolicyResponse" wsaw:Action="urn:updateAutoScalingPolicyResponse"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:updateAutoScalingPolicyAutoScalerServiceInvalidPolicyException"/>
         </wsdl:operation>
-        <wsdl:operation name="removeKubernetesHost">
-            <wsdl:input message="ns:removeKubernetesHostRequest" wsaw:Action="urn:removeKubernetesHost"></wsdl:input>
-            <wsdl:output message="ns:removeKubernetesHostResponse" wsaw:Action="urn:removeKubernetesHostResponse"></wsdl:output>
+        <wsdl:operation name="getApplications">
+            <wsdl:input message="ns:getApplicationsRequest" wsaw:Action="urn:getApplications"/>
+            <wsdl:output message="ns:getApplicationsResponse" wsaw:Action="urn:getApplicationsResponse"/>
         </wsdl:operation>
-        <wsdl:operation name="addPartition">
-            <wsdl:input message="ns:addPartitionRequest" wsaw:Action="urn:addPartition"></wsdl:input>
-            <wsdl:output message="ns:addPartitionResponse" wsaw:Action="urn:addPartitionResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="addDeploymentPolicy">
-            <wsdl:input message="ns:addDeploymentPolicyRequest" wsaw:Action="urn:addDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:addDeploymentPolicyResponse" wsaw:Action="urn:addDeploymentPolicyResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addDeploymentPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
+        <wsdl:operation name="addApplication">
+            <wsdl:input message="ns:addApplicationRequest" wsaw:Action="urn:addApplication"/>
+            <wsdl:fault message="ns:AutoScalerServiceApplicationDefinitionException" name="AutoScalerServiceApplicationDefinitionException" wsaw:Action="urn:addApplicationAutoScalerServiceApplicationDefinitionException"/>
         </wsdl:operation>
         <wsdl:operation name="updateClusterMonitor">
-            <wsdl:input message="ns:updateClusterMonitorRequest" wsaw:Action="urn:updateClusterMonitor"></wsdl:input>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidArgumentException" name="AutoScalerServiceInvalidArgumentException" wsaw:Action="urn:updateClusterMonitorAutoScalerServiceInvalidArgumentException"></wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="getAllKubernetesGroups">
-            <wsdl:input message="ns:getAllKubernetesGroupsRequest" wsaw:Action="urn:getAllKubernetesGroups"></wsdl:input>
-            <wsdl:output message="ns:getAllKubernetesGroupsResponse" wsaw:Action="urn:getAllKubernetesGroupsResponse"></wsdl:output>
+            <wsdl:input message="ns:updateClusterMonitorRequest" wsaw:Action="urn:updateClusterMonitor"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidArgumentException" name="AutoScalerServiceInvalidArgumentException" wsaw:Action="urn:updateClusterMonitorAutoScalerServiceInvalidArgumentException"/>
         </wsdl:operation>
-        <wsdl:operation name="updateDeploymentPolicy">
-            <wsdl:input message="ns:updateDeploymentPolicyRequest" wsaw:Action="urn:updateDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:updateDeploymentPolicyResponse" wsaw:Action="urn:updateDeploymentPolicyResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:updateDeploymentPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
+        <wsdl:operation name="undeployApplication">
+            <wsdl:input message="ns:undeployApplicationRequest" wsaw:Action="urn:undeployApplication"/>
         </wsdl:operation>
         <wsdl:operation name="deployServiceGroup">
-            <wsdl:input message="ns:deployServiceGroupRequest" wsaw:Action="urn:deployServiceGroup"></wsdl:input>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidServiceGroupException" name="AutoScalerServiceInvalidServiceGroupException" wsaw:Action="urn:deployServiceGroupAutoScalerServiceInvalidServiceGroupException"></wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="updateKubernetesHost">
-            <wsdl:input message="ns:updateKubernetesHostRequest" wsaw:Action="urn:updateKubernetesHost"></wsdl:input>
-            <wsdl:output message="ns:updateKubernetesHostResponse" wsaw:Action="urn:updateKubernetesHostResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="getHostsForKubernetesGroup">
-            <wsdl:input message="ns:getHostsForKubernetesGroupRequest" wsaw:Action="urn:getHostsForKubernetesGroup"></wsdl:input>
-            <wsdl:output message="ns:getHostsForKubernetesGroupResponse" wsaw:Action="urn:getHostsForKubernetesGroupResponse"></wsdl:output>
+            <wsdl:input message="ns:deployServiceGroupRequest" wsaw:Action="urn:deployServiceGroup"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidServiceGroupException" name="AutoScalerServiceInvalidServiceGroupException" wsaw:Action="urn:deployServiceGroupAutoScalerServiceInvalidServiceGroupException"/>
         </wsdl:operation>
         <wsdl:operation name="getNetworkPartitions">
-            <wsdl:input message="ns:getNetworkPartitionsRequest" wsaw:Action="urn:getNetworkPartitions"></wsdl:input>
-            <wsdl:output message="ns:getNetworkPartitionsResponse" wsaw:Action="urn:getNetworkPartitionsResponse"></wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="undeployDeploymentPolicy">
-            <wsdl:input message="ns:undeployDeploymentPolicyRequest" wsaw:Action="urn:undeployDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:undeployDeploymentPolicyResponse" wsaw:Action="urn:undeployDeploymentPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:getNetworkPartitionsRequest" wsaw:Action="urn:getNetworkPartitions"/>
+            <wsdl:output message="ns:getNetworkPartitionsResponse" wsaw:Action="urn:getNetworkPartitionsResponse"/>
         </wsdl:operation>
     </wsdl:portType>
     <wsdl:binding name="AutoScalerServiceSoap11Binding" type="ns:AutoScalerServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
-        <wsdl:operation name="addKubernetesGroup">
-            <soap:operation soapAction="urn:addKubernetesGroup" style="document"></soap:operation>
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <wsdl:operation name="getAutoScalingPolicies">
+            <soap:operation soapAction="urn:getAutoScalingPolicies" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
-            </wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="updateKubernetesMaster">
-            <soap:operation soapAction="urn:updateKubernetesMaster" style="document"></soap:operation>
-            <wsdl:input>
-                <soap:body use="literal"></soap:body>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
-            <soap:operation soapAction="urn:getServiceGroups" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getServiceGroups" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceAutoScalerException">
-                <soap:fault use="literal" name="AutoScalerServiceAutoScalerException"></soap:fault>
+                <soap:fault use="literal" name="AutoScalerServiceAutoScalerException"/>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getAllAutoScalingPolicy">
-            <soap:operation soapAction="urn:getAllAutoScalingPolicy" style="document"></soap:operation>
+        <wsdl:operation name="getApplication">
+            <soap:operation soapAction="urn:getApplication" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
-        <wsdl:operation name="getPartitionsOfGroup">
-            <soap:operation soapAction="urn:getPartitionsOfGroup" style="document"></soap:operation>
+        <wsdl:operation name="deployApplication">
+            <soap:operation soapAction="urn:deployApplication" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
+            <wsdl:fault name="AutoScalerServiceApplicationDefinitionException">
+                <soap:fault use="literal" name="AutoScalerServiceApplicationDefinitionException"/>
+            </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <soap:operation soapAction="urn:getDeploymentPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getDeploymentPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+         

<TRUNCATED>

[4/4] stratos git commit: Refining application deployment process

Posted by im...@apache.org.
Refining application deployment process


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

Branch: refs/heads/4.1.0-test
Commit: fbcf3847175c69604fed3b56c97085f16ab7d02c
Parents: e11d743
Author: Imesh Gunaratne <im...@apache.org>
Authored: Mon Dec 15 23:38:22 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon Dec 15 23:43:31 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/api/AutoScalerServiceImpl.java   |  179 +--
 .../applications/pojo/ApplicationContext.java   |   18 +-
 .../applications/topic/ApplicationBuilder.java  |    2 +-
 .../autoscaler/context/AutoscalerContext.java   |   56 +-
 .../interfaces/AutoScalerServiceInterface.java  |  100 +-
 .../autoscaler/registry/RegistryManager.java    |  164 +-
 .../autoscaler/util/AutoScalerConstants.java    |    1 +
 .../controller/util/CloudControllerUtil.java    |   48 +-
 .../stratos/common/beans/ApplicationBean.java   |   32 +-
 .../manager/client/AutoscalerServiceClient.java |   64 +-
 .../beans/ApplicationDefinition.java            |   15 +-
 .../domain/applications/Application.java        |   18 +
 .../rest/endpoint/api/StratosApiV40.java        |   30 +-
 .../rest/endpoint/api/StratosApiV40Utils.java   |   75 -
 .../rest/endpoint/api/StratosApiV41.java        |  212 ++-
 .../rest/endpoint/api/StratosApiV41Utils.java   |  200 ++-
 .../endpoint/util/converter/PojoConverter.java  |  144 +-
 .../src/main/resources/AutoScalerService.wsdl   | 1507 ++++++------------
 18 files changed, 1227 insertions(+), 1638 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
index 9f42599..d5c92e9 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
@@ -71,83 +71,11 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface {
 
     private static final Log log = LogFactory.getLog(AutoScalerServiceImpl.class);
 
-    public DeploymentPolicy[] getAllDeploymentPolicies() {
-        return PolicyManager.getInstance().getDeploymentPolicyList();
-    }
 
-    public AutoscalePolicy[] getAllAutoScalingPolicy() {
+    public AutoscalePolicy[] getAutoScalingPolicies() {
         return PolicyManager.getInstance().getAutoscalePolicyList();
     }
 
-    @Override
-    public DeploymentPolicy[] getValidDeploymentPoliciesforCartridge(String cartridgeType) {
-        ArrayList<DeploymentPolicy> validPolicies = new ArrayList<DeploymentPolicy>();
-
-        for (DeploymentPolicy deploymentPolicy : this.getAllDeploymentPolicies()) {
-            /*try {
-                // call CC API
-                //CloudControllerClient.getInstance().validateDeploymentPolicy(cartridgeType, deploymentPolicy);
-                // if this deployment policy is valid for this cartridge, add it.
-                validPolicies.add(deploymentPolicy);
-            } catch (PartitionValidationException ignoredException) {
-                // if this policy doesn't valid for the given cartridge, add a debug log.
-                if (log.isDebugEnabled()) {
-                    log.debug("Deployment policy [id] " + deploymentPolicy.getApplicationId()
-                            + " is not valid for Cartridge [type] " + cartridgeType, ignoredException);
-                }
-            }*/
-        }
-        return validPolicies.toArray(new DeploymentPolicy[0]);
-    }
-    
-    @Override
-    public boolean deployDeploymentPolicy(DeploymentPolicy policy) {
-        try {
-            String policyId = PolicyManager.getInstance().deployDeploymentPolicy(policy);
-        } catch (InvalidPolicyException e) {
-            log.error("Error while deploying the deployment policy " + policy.getApplicationId(), e);
-        }
-        //Need to start the application Monitor after validation of the deployment policies.
-        //FIXME add validation
-        validateDeploymentPolicy(policy);
-        //Check whether all the clusters are there
-        ApplicationHolder.acquireReadLock();
-        boolean allClusterInitialized = false;
-        String appId = policy.getApplicationId();
-        try {
-            Application application = ApplicationHolder.getApplications().
-                    getApplication(policy.getApplicationId());
-            if (application != null) {
-
-                allClusterInitialized = AutoscalerUtil.allClustersInitialized(application);
-            }
-        } finally {
-            ApplicationHolder.releaseReadLock();
-        }
-
-        if (!AutoscalerContext.getInstance().containsPendingMonitor(appId)
-                                    || !AutoscalerContext.getInstance().monitorExists(appId)) {
-            if(allClusterInitialized) {
-                AutoscalerUtil.getInstance().
-                        startApplicationMonitor(appId);
-            } else {
-                log.info("The application clusters are not yet created. " +
-                        "Waiting for them to be created");
-            }
-        } else {
-            log.info("The application Monitor has already been created for [Application] " + appId);
-        }
-        //FIXME add proper return value when validation is done properly
-        return true;
-    }
-
-    @Override
-    public String addDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws InvalidPolicyException {
-        String policyId = PolicyManager.getInstance().deployDeploymentPolicy(deploymentPolicy);
-        
-        return policyId;
-    }
-
     private boolean validateDeploymentPolicy(DeploymentPolicy deploymentPolicy) {
 
         for(ChildPolicy childPolicy : deploymentPolicy.getChildPolicies()) {
@@ -211,16 +139,6 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface {
     }
 
     @Override
-    public boolean undeployDeploymentPolicy(String applicationId) {
-        return ApplicationBuilder.handleApplicationPolicyUndeployed(applicationId);
-    }
-
-    @Override
-    public boolean updateDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws InvalidPolicyException {
-        return PolicyManager.getInstance().updateDeploymentPolicy(deploymentPolicy);
-    }
-
-    @Override
     public boolean addAutoScalingPolicy(AutoscalePolicy autoscalePolicy) throws InvalidPolicyException {
         return PolicyManager.getInstance().deployAutoscalePolicy(autoscalePolicy);
     }
@@ -245,37 +163,94 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface {
         return PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getApplicationLevelNetworkPartitions();
     }
 
-    //    @Override
-    public Partition[] getPartitionsOfGroup(String deploymentPolicyId, String groupId) {
-        DeploymentPolicy depPol = this.getDeploymentPolicy(deploymentPolicyId);
-        if (null == depPol) {
-            return null;
+    @Override
+    public void addApplication(ApplicationContext applicationContext)
+            throws ApplicationDefinitionException {
+        ApplicationParser applicationParser = new DefaultApplicationParser();
+        applicationParser.parse(applicationContext);
+        applicationContext.setStatus(ApplicationContext.STATUS_CREATED);
+        AutoscalerContext.getInstance().addApplicationContext(applicationContext);
+        if(log.isInfoEnabled()) {
+            log.info(String.format("Application added successfully: [application-id] ",
+                    applicationContext.getApplicationId()));
         }
+    }
 
-        ApplicationLevelNetworkPartition group = depPol.getApplicationLevelNetworkPartition(groupId);
-
-        if (group == null) {
-            return null;
-        }
+    @Override
+    public ApplicationContext getApplication(String applicationId) {
+        return AutoscalerContext.getInstance().getApplicationContext(applicationId);
+    }
 
-        return group.getPartitions();
+    @Override
+    public ApplicationContext[] getApplications() {
+        return AutoscalerContext.getInstance().getApplicationContexts().
+                toArray(new ApplicationContext[AutoscalerContext.getInstance().getApplicationContexts().size()]);
     }
 
     @Override
-    public void deployApplicationDefinition(ApplicationContext applicationContext)
-            throws ApplicationDefinitionException {
+    public boolean deployApplication(String applicationId, DeploymentPolicy policy) throws ApplicationDefinitionException {
+        ApplicationContext applicationContext = RegistryManager.getInstance().getApplicationContext(applicationId);
+        if(applicationContext == null) {
+            throw new RuntimeException("Application not found: " + applicationId);
+        }
 
         ApplicationParser applicationParser = new DefaultApplicationParser();
         Application application = applicationParser.parse(applicationContext);
-        // publishMetadata(applicationParser, application.getUniqueIdentifier());
-        ApplicationBuilder.handleApplicationCreated(application,
-                applicationParser.getApplicationClusterContexts());
+        ApplicationBuilder.handleApplicationCreated(application, applicationParser.getApplicationClusterContexts());
+
+        try {
+            String policyId = PolicyManager.getInstance().deployDeploymentPolicy(policy);
+        } catch (InvalidPolicyException e) {
+            log.error("Error while deploying the deployment policy " + policy.getApplicationId(), e);
+        }
+
+        //Need to start the application Monitor after validation of the deployment policies.
+        //FIXME add validation
+        validateDeploymentPolicy(policy);
+        //Check whether all the clusters are there
+        ApplicationHolder.acquireReadLock();
+        boolean allClusterInitialized = false;
+        try {
+            application = ApplicationHolder.getApplications().getApplication(policy.getApplicationId());
+            if (application != null) {
+                allClusterInitialized = AutoscalerUtil.allClustersInitialized(application);
+            }
+        } finally {
+            ApplicationHolder.releaseReadLock();
+        }
+
+        if (!AutoscalerContext.getInstance().containsPendingMonitor(applicationId)
+                || !AutoscalerContext.getInstance().monitorExists(applicationId)) {
+            if(allClusterInitialized) {
+                AutoscalerUtil.getInstance().startApplicationMonitor(applicationId);
+            } else {
+                log.info("The application clusters are not yet created. " +
+                        "Waiting for them to be created");
+            }
+        } else {
+            log.info("The application Monitor has already been created for [Application] " + applicationId);
+        }
+        applicationContext.setStatus(ApplicationContext.STATUS_DEPLOYED);
+        AutoscalerContext.getInstance().updateApplicationContext(applicationContext);
+        return true;
     }
 
     @Override
-    public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain)
-            throws ApplicationDefinitionException {
-        ApplicationBuilder.handleApplicationDeleted(applicationId);
+    public void undeployApplication(String applicationId) {
+        ApplicationBuilder.handleApplicationUndeployed(applicationId);
+
+        ApplicationContext applicationContext = AutoscalerContext.getInstance().getApplicationContext(applicationId);
+        applicationContext.setStatus(ApplicationContext.STATUS_CREATED);
+        AutoscalerContext.getInstance().updateApplicationContext(applicationContext);
+    }
+
+    @Override
+    public void deleteApplication(String applicationId) {
+        AutoscalerContext.getInstance().removeApplicationContext(applicationId);
+        if(log.isInfoEnabled()) {
+            log.info(String.format("Application deleted successfully: [application-id] ",
+                    applicationId));
+        }
     }
 
     public void updateClusterMonitor(String clusterId, Properties properties) throws InvalidArgumentException {

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
index 97fc537..6f48263 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
@@ -27,19 +27,17 @@ public class ApplicationContext implements Serializable {
 
     private static final long serialVersionUID = 6704036501869668646L;
 
-    private int tenantId;
+    public static final String STATUS_CREATED = "Created";
+    public static final String STATUS_DEPLOYED = "Deployed";
 
+    private int tenantId;
     private String tenantDomain;
-
     private String teantAdminUsername;
-
     private String applicationId;
-
     private String alias;
-
     private ComponentContext componentContext;
-
     private Properties properties;
+    private String status;
 
     public ApplicationContext() {
     }
@@ -100,4 +98,12 @@ public class ApplicationContext implements Serializable {
         this.properties = properties;
     }
 
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
index fb5909f..c85fe7f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -183,7 +183,7 @@ public class ApplicationBuilder {
         }
     }
 
-    public static void handleApplicationDeleted(String appId) {
+    public static void handleApplicationUndeployed(String appId) {
         if (log.isDebugEnabled()) {
             log.debug("Handling application unDeployment for [application-id] " + appId);
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
index 2452255..ce5e553 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
@@ -20,13 +20,13 @@
  */
 package org.apache.stratos.autoscaler.context;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor;
+import org.apache.stratos.autoscaler.registry.RegistryManager;
 
 /**
  * It holds all cluster monitors which are active in stratos.
@@ -35,6 +35,8 @@ public class AutoscalerContext {
 
     private static final AutoscalerContext INSTANCE = new AutoscalerContext();
 
+    // Map<ApplicationId, ApplicationContext>
+    private Map<String, ApplicationContext> applicationContextMap;
     // Map<ClusterId, AbstractClusterMonitor>
     private Map<String, AbstractClusterMonitor> clusterMonitors;
     // Map<ApplicationId, ApplicationMonitor>
@@ -43,11 +45,29 @@ public class AutoscalerContext {
     private List<String> pendingApplicationMonitors;
 
     private AutoscalerContext() {
+        applicationContextMap = readApplicationContextsFromRegistry();
+        if(applicationContextMap == null) {
+            applicationContextMap = new ConcurrentHashMap<String, ApplicationContext>();
+        }
         setClusterMonitors(new HashMap<String, AbstractClusterMonitor>());
         setApplicationMonitors(new HashMap<String, ApplicationMonitor>());
         pendingApplicationMonitors = new ArrayList<String>();
     }
 
+    private Map<String, ApplicationContext> readApplicationContextsFromRegistry() {
+        String[] resourcePaths = RegistryManager.getInstance().getApplicationContextResourcePaths();
+        if((resourcePaths == null) || (resourcePaths.length == 0)) {
+            return null;
+        }
+
+        Map<String, ApplicationContext> applicationContextMap = new ConcurrentHashMap<String, ApplicationContext>();
+        for(String resourcePath : resourcePaths) {
+            ApplicationContext applicationContext = RegistryManager.getInstance().getApplicationContextByResourcePath(resourcePath);
+            applicationContextMap.put(applicationContext.getApplicationId(), applicationContext);
+        }
+        return applicationContextMap;
+    }
+
     public static AutoscalerContext getInstance() {
         return INSTANCE;
     }
@@ -115,4 +135,32 @@ public class AutoscalerContext {
     public boolean monitorExists(String appId) {
         return this.applicationMonitors.containsKey(appId);
     }
+
+    public void addApplicationContext(ApplicationContext applicationContext) {
+        applicationContextMap.put(applicationContext.getApplicationId(), applicationContext);
+        RegistryManager.getInstance().persistApplicationContext(applicationContext);
+    }
+
+    public void removeApplicationContext(String applicationId) {
+        if(applicationContextMap.containsKey(applicationId)) {
+            applicationContextMap.remove(applicationId);
+            RegistryManager.getInstance().removeApplicationContext(applicationId);
+        }
+    }
+
+    public ApplicationContext getApplicationContext(String applicationId) {
+        if(applicationContextMap.containsKey(applicationId)) {
+            return applicationContextMap.get(applicationId);
+        }
+        return null;
+    }
+
+    public Collection<ApplicationContext> getApplicationContexts() {
+        return applicationContextMap.values();
+    }
+
+    public void updateApplicationContext(ApplicationContext applicationContext) {
+        applicationContextMap.put(applicationContext.getApplicationId(), applicationContext);
+        RegistryManager.getInstance().persistApplicationContext(applicationContext);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
index 096450a..9b5ea6a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
@@ -31,29 +31,87 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.common.Properties;
 
 public interface AutoScalerServiceInterface {
+    /**
+     * Add autoscaling policy
+     * @param autoscalePolicy
+     * @return
+     * @throws InvalidPolicyException
+     */
+    public boolean addAutoScalingPolicy(AutoscalePolicy autoscalePolicy) throws InvalidPolicyException;
 
-    public DeploymentPolicy[] getAllDeploymentPolicies();
+    /**
+     * Get an autoscaling policy
+     * @param autoscalingPolicyId
+     * @return
+     */
+    public AutoscalePolicy getAutoscalingPolicy(String autoscalingPolicyId);
 
-    public String addDeploymentPolicy(DeploymentPolicy depPolicy) throws InvalidPolicyException;
-    
-    public boolean deployDeploymentPolicy(DeploymentPolicy deploymentPolicy);
+    /**
+     * Get autoscaling policies
+     * @return
+     */
+    public AutoscalePolicy[] getAutoScalingPolicies();
 
-    public boolean undeployDeploymentPolicy(String deploymentPolicyName);
+    /**
+     * Update an autoscaling policy
+     * @param autoscalePolicy
+     * @return
+     * @throws InvalidPolicyException
+     */
+    public boolean updateAutoScalingPolicy(AutoscalePolicy autoscalePolicy) throws InvalidPolicyException;
 
-    public boolean updateDeploymentPolicy(DeploymentPolicy depPolicy) throws InvalidPolicyException;
+    /**
+     * Add an application
+     *
+     * @param applicationContext {@link org.apache.stratos.autoscaler.applications.pojo.ApplicationContext}
+     * @throws ApplicationDefinitionException if an error occurs
+     */
+    public void addApplication(ApplicationContext applicationContext) throws ApplicationDefinitionException;
 
-    public AutoscalePolicy[] getAllAutoScalingPolicy();
+    /**
+     * Get an application
+     * @param applicationId
+     */
+    public ApplicationContext getApplication(String applicationId);
 
-    public boolean addAutoScalingPolicy(AutoscalePolicy aspolicy) throws InvalidPolicyException;
+    /**
+     * Get all applications
+     */
+    public ApplicationContext[] getApplications();
 
-    public boolean updateAutoScalingPolicy(AutoscalePolicy aspolicy) throws InvalidPolicyException;
+    /**
+     * Deploy an application in created state
+     * @param applicationId
+     * @param deploymentPolicy
+     * @return
+     */
+    public boolean deployApplication(String applicationId, DeploymentPolicy deploymentPolicy) throws ApplicationDefinitionException;
 
-    public DeploymentPolicy[] getValidDeploymentPoliciesforCartridge(String cartridgeType);
+    /**
+     * Undeploy an application in deployed state
+     * @param applicationId
+     * @return
+     */
+    public void undeployApplication(String applicationId);
 
-    public DeploymentPolicy getDeploymentPolicy(String deploymentPolicyId);
+    /**
+     * Delete an application
+     * @param applicationId
+     */
+    public void deleteApplication(String applicationId);
 
-    public AutoscalePolicy getAutoscalingPolicy(String autoscalingPolicyId);
+    /**
+     * Returns a deployment policy of an application
+     * @param applicationId
+     * @return
+     */
+    public DeploymentPolicy getDeploymentPolicy(String applicationId);
 
+    /**
+     * Returns network partitions of a deployment policy
+     * @param deploymentPolicyId
+     * @return
+     */
     public org.apache.stratos.autoscaler.pojo.policy.deployment.partition.network.ApplicationLevelNetworkPartition[] getNetworkPartitions(String deploymentPolicyId);
 
     /**
@@ -62,24 +120,6 @@ public interface AutoScalerServiceInterface {
      * @param properties updated properties.
      */
     void updateClusterMonitor(String clusterId, Properties properties) throws InvalidArgumentException;
-    
-    /**
-     * deploys an Application Definition
-     *
-     * @param applicationContext {@link org.apache.stratos.autoscaler.applications.pojo.ApplicationContext} object
-     * @throws ApplicationDefinitionException if an error is encountered
-     */
-    public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException;
-
-    /**
-     * undeploys an Application Definition
-     *
-     * @param applicationId Id of the Application to be undeployed
-     * @throws ApplicationDefinitionException if an error is encountered
-     */
-    public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain)
-            throws ApplicationDefinitionException;
-
 
     /**
      * Get service group by name

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index 90fa388..28e107c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -24,7 +24,7 @@ package org.apache.stratos.autoscaler.registry;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-//import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
 import org.apache.stratos.autoscaler.pojo.ServiceGroup;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
@@ -117,24 +117,6 @@ public class RegistryManager {
         }
     }
 
-    public void persistPartition(Partition partition) {
-        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.PARTITION_RESOURCE + "/" + partition.getId();
-        persist(partition, resourcePath);
-        if (log.isDebugEnabled()) {
-            log.debug(String.format("Partition written to registry: [id] %s [provider] %s [min] %d [max] %d",
-                    partition.getId(), partition.getProvider(), partition.getPartitionMin(), partition.getPartitionMax()));
-        }
-    }
-
-//    public void persistNetworkPartitionIbHolder(NetworkPartitionLbHolder nwPartitionLbHolder) {
-//        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants
-//                .NETWORK_PARTITION_LB_HOLDER_RESOURCE + "/" + nwPartitionLbHolder.getNetworkPartitionId();
-//        persist(nwPartitionLbHolder, resourcePath);
-//        if (log.isDebugEnabled()) {
-//            log.debug("NetworkPartitionContext written to registry: " + nwPartitionLbHolder.toString());
-//        }
-//    }
-
     public void persistAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
         persist(autoscalePolicy, resourcePath);
@@ -152,7 +134,6 @@ public class RegistryManager {
         }
     }
 
-
     public void persistApplication(Application application) {
 
         try {
@@ -174,7 +155,6 @@ public class RegistryManager {
     }
 
     public String[] getApplicationResourcePaths() {
-
         try {
             PrivilegedCarbonContext.startTenantFlow();
             PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
@@ -192,11 +172,9 @@ public class RegistryManager {
                     return null;
                 }
             }
-
         } finally {
             PrivilegedCarbonContext.endTenantFlow();
         }
-
         return null;
     }
 
@@ -211,8 +189,7 @@ public class RegistryManager {
             Object obj = retrieve(applicationResourcePath);
             if (obj != null) {
                 try {
-                    Object dataObj = Deserializer
-                            .deserializeFromByteArray((byte[]) obj);
+                    Object dataObj = Deserializer.deserializeFromByteArray((byte[]) obj);
                     if (dataObj instanceof Application) {
                         return (Application) dataObj;
                     } else {
@@ -223,23 +200,72 @@ public class RegistryManager {
                     log.warn(msg, e);
                 }
             }
-            /*if (obj != null) {
-                if (obj instanceof Application) {
-                    return (Application) obj;
+        } finally {
+            PrivilegedCarbonContext.endTenantFlow();
+        }
+        return null;
+    }
+
+    public void removeApplication(String applicationId) {
+        try {
+            PrivilegedCarbonContext.startTenantFlow();
+            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+            carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+            carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+
+            delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
+                    "/" + applicationId);
+
+        } finally {
+            PrivilegedCarbonContext.endTenantFlow();
+        }
+    }
+
+    public void persistApplicationContext(ApplicationContext applicationContext) {
+
+        try {
+            PrivilegedCarbonContext.startTenantFlow();
+            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+            carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+            carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+
+            String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE +
+                    AutoScalerConstants.APPLICATION_CONTEXTS_RESOURCE + "/" + applicationContext.getApplicationId();
+            persist(applicationContext, resourcePath);
+            if (log.isDebugEnabled()) {
+                log.debug("Application context [" + applicationContext.getApplicationId() + "] " +
+                        "persisted successfully in the Autoscaler Registry");
+            }
+        } finally {
+            PrivilegedCarbonContext.endTenantFlow();
+        }
+    }
+
+    public String[] getApplicationContextResourcePaths() {
+        try {
+            PrivilegedCarbonContext.startTenantFlow();
+            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+            carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+            carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+
+            Object obj = retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE +
+                    AutoScalerConstants.APPLICATION_CONTEXTS_RESOURCE);
+
+            if (obj != null) {
+                if (obj instanceof String[]) {
+                    return (String[]) obj;
                 } else {
-                    log.warn("Expected object type not found for Application " + applicationResourcePath + " in Registry");
+                    log.warn("Expected object type not found for Applications in Registry");
                     return null;
                 }
-            }*/
-
+            }
         } finally {
             PrivilegedCarbonContext.endTenantFlow();
         }
-
         return null;
     }
 
-    public void removeApplication(String applicationId) {
+    public ApplicationContext getApplicationContext(String applicationId) {
 
         try {
             PrivilegedCarbonContext.startTenantFlow();
@@ -247,13 +273,48 @@ public class RegistryManager {
             carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
             carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
 
-            delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
-                    "/" + applicationId);
+            String applicationResourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE +
+                    AutoScalerConstants.APPLICATION_CONTEXTS_RESOURCE + "/" + applicationId;
+            return (ApplicationContext) getApplicationContextByResourcePath(applicationResourcePath);
+        } finally {
+            PrivilegedCarbonContext.endTenantFlow();
+        }
+    }
+
+    public ApplicationContext getApplicationContextByResourcePath(String resourcePath) {
 
+        try {
+            PrivilegedCarbonContext.startTenantFlow();
+            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+            carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+            carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+
+            Object obj = retrieve(resourcePath);
+            if (obj != null) {
+                try {
+                    return (ApplicationContext) Deserializer.deserializeFromByteArray((byte[]) obj);
+                } catch (Exception e) {
+                    log.error("Could not deserialize application context", e);
+                }
+            }
+            return null;
         } finally {
             PrivilegedCarbonContext.endTenantFlow();
         }
+    }
 
+    public void removeApplicationContext(String applicationId) {
+        try {
+            PrivilegedCarbonContext.startTenantFlow();
+            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+            carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+            carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+
+            delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATION_CONTEXTS_RESOURCE +
+                    "/" + applicationId);
+        } finally {
+            PrivilegedCarbonContext.endTenantFlow();
+        }
     }
 
     public void persistServiceGroup(ServiceGroup servicegroup) {
@@ -324,39 +385,6 @@ public class RegistryManager {
         return partitionList;
     }
 
-//    public List<NetworkPartitionLbHolder> retrieveNetworkPartitionLbHolders() {
-//        List<NetworkPartitionLbHolder> nwPartitionLbHolderList = new ArrayList<NetworkPartitionLbHolder>();
-//        RegistryManager registryManager = RegistryManager.getInstance();
-//        String[] partitionsResourceList = (String[]) registryManager.retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE +
-//                AutoScalerConstants.NETWORK_PARTITION_LB_HOLDER_RESOURCE);
-//
-//        if (partitionsResourceList != null) {
-//            NetworkPartitionLbHolder nwPartitionLbHolder;
-//            for (String resourcePath : partitionsResourceList) {
-//                Object serializedObj = registryManager.retrieve(resourcePath);
-//                if (serializedObj != null) {
-//                    try {
-//
-//                        Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
-//                        if (dataObj instanceof NetworkPartitionLbHolder) {
-//                            nwPartitionLbHolder = (NetworkPartitionLbHolder) dataObj;
-//                            if (log.isDebugEnabled()) {
-//                                log.debug(String.format("NetworkPartitionLbHolder read from registry: " + nwPartitionLbHolder.toString()));
-//                            }
-//                            nwPartitionLbHolderList.add(nwPartitionLbHolder);
-//                        } else {
-//                            return null;
-//                        }
-//                    } catch (Exception e) {
-//                        String msg = "Unable to retrieve data from Registry. Hence, any historical NetworkPartitionLbHolder will not get reflected.";
-//                        log.warn(msg, e);
-//                    }
-//                }
-//            }
-//        }
-//        return nwPartitionLbHolderList;
-//    }
-
     public List<AutoscalePolicy> retrieveASPolicies() {
         List<AutoscalePolicy> asPolicyList = new ArrayList<AutoscalePolicy>();
         RegistryManager registryManager = RegistryManager.getInstance();

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
index f5fede9..ff4959f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
@@ -40,6 +40,7 @@ public final class AutoScalerConstants {
 	public static final String AS_POLICY_RESOURCE = "/policies/autoscalingPolicies";
 	public static final String DEPLOYMENT_POLICY_RESOURCE = "/policies/deploymentPolicies";
     public static final String APPLICATIONS_RESOURCE = "/applications";
+    public static final String APPLICATION_CONTEXTS_RESOURCE = "/applicationContexts";
 
     /**
      * Cluster monitoring  interval

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
index c58eedc..dbf36bc 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
@@ -207,30 +207,30 @@ public class CloudControllerUtil {
 	  
     public static CartridgeInfo toCartridgeInfo(Cartridge cartridge) {
 
-		CartridgeInfo carInfo = new CartridgeInfo();
-		carInfo.setType(cartridge.getType());
-		carInfo.setDisplayName(cartridge.getDisplayName());
-		carInfo.setDescription(cartridge.getDescription());
-		carInfo.setHostName(cartridge.getHostName());
-		carInfo.setDeploymentDirs(cartridge.getDeploymentDirs());
-		carInfo.setProvider(cartridge.getProvider());
-	    carInfo.setCategory(cartridge.getCategory());
-		carInfo.setVersion(cartridge.getVersion());
-		carInfo.setMultiTenant(cartridge.isMultiTenant());
-		carInfo.setBaseDir(cartridge.getBaseDir());
-		carInfo.setLbConfig(cartridge.getLbConfig());
-		carInfo.setDefaultAutoscalingPolicy(cartridge.getDefaultAutoscalingPolicy());
-        carInfo.setDefaultDeploymentPolicy(cartridge.getDefaultDeploymentPolicy());
-		carInfo.setPortMappings(cartridge.getPortMappings()
-		                                 .toArray(new PortMapping[cartridge.getPortMappings()
-		                                                                   .size()]));
-		carInfo.setAppTypes(cartridge.getAppTypeMappings()
-                                .toArray(new AppType[cartridge.getAppTypeMappings()
-                                                                  .size()]));
-        carInfo.setServiceGroup(cartridge.getServiceGroup());
+		CartridgeInfo cartridgeInfo = new CartridgeInfo();
+		cartridgeInfo.setType(cartridge.getType());
+		cartridgeInfo.setDisplayName(cartridge.getDisplayName());
+		cartridgeInfo.setDescription(cartridge.getDescription());
+		cartridgeInfo.setHostName(cartridge.getHostName());
+		cartridgeInfo.setDeploymentDirs(cartridge.getDeploymentDirs());
+		cartridgeInfo.setProvider(cartridge.getProvider());
+	    cartridgeInfo.setCategory(cartridge.getCategory());
+		cartridgeInfo.setVersion(cartridge.getVersion());
+		cartridgeInfo.setMultiTenant(cartridge.isMultiTenant());
+		cartridgeInfo.setBaseDir(cartridge.getBaseDir());
+		cartridgeInfo.setLbConfig(cartridge.getLbConfig());
+		cartridgeInfo.setDefaultAutoscalingPolicy(cartridge.getDefaultAutoscalingPolicy());
+        cartridgeInfo.setDefaultDeploymentPolicy(cartridge.getDefaultDeploymentPolicy());
+		cartridgeInfo.setPortMappings(cartridge.getPortMappings()
+                .toArray(new PortMapping[cartridge.getPortMappings()
+                        .size()]));
+		cartridgeInfo.setAppTypes(cartridge.getAppTypeMappings()
+                .toArray(new AppType[cartridge.getAppTypeMappings()
+                        .size()]));
+        cartridgeInfo.setServiceGroup(cartridge.getServiceGroup());
 		
 		List<Property> propList = new ArrayList<Property>();
-        carInfo.setPersistence(cartridge.getPersistence());
+        cartridgeInfo.setPersistence(cartridge.getPersistence());
 		
 		for (Iterator<?> iterator = cartridge.getProperties().entrySet().iterator(); iterator.hasNext();) {
 	        @SuppressWarnings("unchecked")
@@ -241,9 +241,9 @@ public class CloudControllerUtil {
         }
 		Property[] props = new Property[propList.size()];
 		
-		carInfo.setProperties(propList.toArray(props));
+		cartridgeInfo.setProperties(propList.toArray(props));
 
-		return carInfo;
+		return cartridgeInfo;
 	}
 
     public static void sleep(long time){

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/ApplicationBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/ApplicationBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/ApplicationBean.java
index 7eb94e5..d64eb23 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/ApplicationBean.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/ApplicationBean.java
@@ -11,13 +11,14 @@ import java.util.List;
 @XmlRootElement(name="applications")
 public class ApplicationBean {
     private String id;
+    private String name;
+    private String description;
     private String tenantDomain;
     private String tenantAdminUsername;
     private List<GroupBean> groups = null;
     private List<Cluster> clusters = null;
     private List<Instance> instances;
 
-
     public ApplicationBean(){
         this.setGroups(new ArrayList<GroupBean>());
         this.setClusters(new ArrayList<Cluster>());
@@ -26,10 +27,30 @@ public class ApplicationBean {
         this.getGroups().add(groupBean);
     }
 
+    public String getId() {
+        return id;
+    }
+
     public void setId(String id) {
         this.id = id;
     }
 
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
     public void setTenantDomain(String tenantDomain) {
         this.tenantDomain = tenantDomain;
     }
@@ -38,10 +59,6 @@ public class ApplicationBean {
         this.tenantAdminUsername = tenantAdminUsername;
     }
 
-    public String getId() {
-        return id;
-    }
-
     public String getTenantDomain() {
         return tenantDomain;
     }
@@ -49,14 +66,15 @@ public class ApplicationBean {
     public String getTenantAdminUsername() {
         return tenantAdminUsername;
     }
+
 	public List<Instance> getInstances() {
 		return instances;
 	}
-	public void setInstances(List<Instance> instances) {
+
+    public void setInstances(List<Instance> instances) {
 		this.instances = instances;
 	}
 
-
     public List<GroupBean> getGroups() {
         return groups;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
index 545dcf5..394fd1f 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
@@ -96,7 +96,7 @@ public class AutoscalerServiceClient {
             throws RemoteException {
 
         org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy[] autoscalePolicies;
-        autoscalePolicies = stub.getAllAutoScalingPolicy();
+        autoscalePolicies = stub.getAutoScalingPolicies();
 
         return autoscalePolicies;
     }
@@ -110,29 +110,6 @@ public class AutoscalerServiceClient {
         return autoscalePolicy;
     }
 
-    public org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy[] getDeploymentPolicies()
-            throws RemoteException {
-
-        org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy[] deploymentPolicies;
-        deploymentPolicies = stub.getAllDeploymentPolicies();
-
-        return deploymentPolicies;
-    }
-
-    public org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy[] getDeploymentPolicies(
-            String cartridgeType) throws RemoteException {
-
-        org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy[] deploymentPolicies;
-        deploymentPolicies = stub
-                .getValidDeploymentPoliciesforCartridge(cartridgeType);
-
-        return deploymentPolicies;
-    }
-
-    public void unDeployDeploymentPolicy(String applicationId) throws RemoteException {
-        stub.undeployDeploymentPolicy(applicationId);
-    }
-
     public org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy getDeploymentPolicy(String deploymentPolicyId) throws RemoteException {
 
         org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy deploymentPolicy;
@@ -141,25 +118,32 @@ public class AutoscalerServiceClient {
         return deploymentPolicy;
     }
 
-    public String addDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws RemoteException,
-    AutoScalerServiceInvalidPolicyExceptionException {
+    public void addApplication(ApplicationContext applicationContext) throws AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
+        stub.addApplication(applicationContext);
+    }
 
-    	return stub.addDeploymentPolicy(deploymentPolicy);
+    public ApplicationContext getApplication(String applicationId) throws RemoteException {
+        return stub.getApplication(applicationId);
+    }
 
+    public ApplicationContext[] getApplications() throws RemoteException {
+        return stub.getApplications();
     }
-    
-    public boolean deployDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws RemoteException,
-            AutoScalerServiceInvalidPolicyExceptionException {
 
-        return stub.deployDeploymentPolicy(deploymentPolicy);
+    public boolean deployApplication(String applicationId, DeploymentPolicy deploymentPolicy) throws RemoteException,
+            AutoScalerServiceInvalidPolicyExceptionException, AutoScalerServiceApplicationDefinitionExceptionException {
 
-    }
+        return stub.deployApplication(applicationId, deploymentPolicy);
 
-    public boolean updateDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws RemoteException,
-            AutoScalerServiceInvalidPolicyExceptionException {
+    }
 
-        return stub.updateDeploymentPolicy(deploymentPolicy);
+    public void undeployApplication(String applicationId) throws
+            AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
+        stub.undeployApplication(applicationId);
+    }
 
+    public void deleteApplication(String applicationId) throws RemoteException {
+        stub.deleteApplication(applicationId);
     }
 
     public boolean deployAutoscalingPolicy(AutoscalePolicy autoScalePolicy) throws RemoteException,
@@ -186,16 +170,6 @@ public class AutoscalerServiceClient {
         stub.deployServiceGroup(serviceGroup);
     }
 
-    public void deployApplication(ApplicationContext applicationContext) throws
-            AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
-        stub.deployApplicationDefinition(applicationContext);
-    }
-
-    public void undeployApplication(String applicationId, int tenantId, String tenantDomain) throws
-            AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
-        stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain);
-    }
-
     public void updateClusterMonitor(String clusterId, Properties properties) throws RemoteException, AutoScalerServiceInvalidArgumentExceptionException {
         stub.updateClusterMonitor(clusterId, ApplicationManagementUtil.toAutoscalerStubProperties(properties));
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java
index 2a115e5..9701c34 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java
@@ -30,11 +30,9 @@ public class ApplicationDefinition implements Serializable {
     private static final long serialVersionUID = -2829206180707597651L;
 
 	private String applicationId;
-
     private String alias;
-
     private ComponentDefinition components;
-    
+    private String status;
     private List<PropertyBean> property;
     
     public String getApplicationId() {
@@ -61,12 +59,19 @@ public class ApplicationDefinition implements Serializable {
         this.components = components;
     }
 
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
 	public List<PropertyBean> getProperty() {
 		return property;
 	}
 
 	public void setProperty(List<PropertyBean> property) {
 		this.property = property;
-	}   
-    
+	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
index b8e3ee3..6b01ddb 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
@@ -36,6 +36,8 @@ public class Application extends ParentComponent<ApplicationInstance> {
     private static final long serialVersionUID = -5092959597171649688L;
     // Unique id for the Application, defined in Application Definition
     private String id;
+    private String name;
+    private String description;
     // Key used for authentication (with metadata service, etc.)
     private String key;
     // tenant id
@@ -136,4 +138,20 @@ public class Application extends ParentComponent<ApplicationInstance> {
         return null;
 
     }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
index 3cb5f24..81be753 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
@@ -167,10 +167,10 @@ public class StratosApiV40 extends AbstractApi {
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")
     @SuperTenantService(true)
-    public StratosApiResponse deployDeploymentPolicyDefinition (DeploymentPolicy deploymentPolicy)
+    public Response deployDeploymentPolicyDefinition(DeploymentPolicy deploymentPolicy)
             throws RestAPIException {
-
-        return StratosApiV40Utils.deployDeploymentPolicy(deploymentPolicy);
+        // Not supported in 4.1.0
+        return Response.status(Response.Status.GONE).build();
     }
 
     @GET
@@ -178,9 +178,9 @@ public class StratosApiV40 extends AbstractApi {
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Partition[] getPartitions () throws RestAPIException {
-
-        return StratosApiV40Utils.getAvailablePartitions();
+    public Response getPartitions() throws RestAPIException {
+        // Not supported in 4.1.0
+        return Response.status(Response.Status.GONE).build();
     }
 
     @GET
@@ -252,9 +252,9 @@ public class StratosApiV40 extends AbstractApi {
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public DeploymentPolicy[] getDeploymentPolicies () throws RestAPIException {
-
-        return StratosApiV40Utils.getDeploymentPolicies();
+    public Response getDeploymentPolicies() throws RestAPIException {
+        // Not supported in 4.1.0
+        return Response.status(Response.Status.GONE).build();
     }
 
     @GET
@@ -262,10 +262,10 @@ public class StratosApiV40 extends AbstractApi {
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public DeploymentPolicy getDeploymentPolicies (@PathParam("deploymentPolicyId") String deploymentPolicyId)
+    public Response getDeploymentPolicies(@PathParam("deploymentPolicyId") String deploymentPolicyId)
             throws RestAPIException {
-
-        return StratosApiV40Utils.getDeploymentPolicy(deploymentPolicyId);
+        // Not supported in 4.1.0
+        return Response.status(Response.Status.GONE).build();
     }
 
     @GET
@@ -273,10 +273,10 @@ public class StratosApiV40 extends AbstractApi {
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public DeploymentPolicy[] getValidDeploymentPolicies (@PathParam("cartridgeType") String cartridgeType)
+    public Response getValidDeploymentPolicies(@PathParam("cartridgeType") String cartridgeType)
             throws RestAPIException {
-
-        return StratosApiV40Utils.getDeploymentPolicies(cartridgeType);
+        // Not supported in 4.1.0
+        return Response.status(Response.Status.GONE).build();
     }
 
     @GET

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
index 1ab2c33..d129da0 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
@@ -225,35 +225,6 @@ public class StratosApiV40Utils {
         return stratosApiResponse;
     }
 
-    public static StratosApiResponse deployDeploymentPolicy(
-            org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy deploymentPolicyBean)
-            throws RestAPIException {
-
-        String policyId = null;
-
-        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
-        if (autoscalerServiceClient != null) {
-
-            DeploymentPolicy deploymentPolicy = PojoConverter.convetToASDeploymentPolicyPojo(deploymentPolicyBean);
-
-            try {
-                policyId = autoscalerServiceClient.addDeploymentPolicy(deploymentPolicy);
-            } catch (RemoteException e) {
-                log.error(e.getMessage(), e);
-                throw new RestAPIException(e.getMessage(), e);
-            } catch (AutoScalerServiceInvalidPolicyExceptionException e) {
-                String message = e.getFaultMessage().getInvalidPolicyException().getMessage();
-                log.error(message, e);
-                throw new RestAPIException(message, e);
-            }
-
-        }
-
-        StratosApiResponse stratosApiResponse = new StratosApiResponse();
-        stratosApiResponse.setMessage("Successfully deployed deployment policy definition with type " + policyId);
-        return stratosApiResponse;
-    }
-
     private static CloudControllerServiceClient getCloudControllerServiceClient () throws RestAPIException {
 
         try {
@@ -394,52 +365,6 @@ public class StratosApiV40Utils {
         return PojoConverter.populateAutoscalePojo(autoscalePolicy);
     }
 
-    public static org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy[]
-    getDeploymentPolicies () throws RestAPIException {
-
-        DeploymentPolicy [] deploymentPolicies = null;
-        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
-        if (autoscalerServiceClient != null) {
-            try {
-                deploymentPolicies = autoscalerServiceClient.getDeploymentPolicies();
-            } catch (RemoteException e) {
-                String errorMsg = "Error getting available deployment policies. Cause : " + e.getMessage();
-                log.error(errorMsg, e);
-                throw new RestAPIException(errorMsg, e);
-            }
-        }
-
-
-
-        return PojoConverter.populateDeploymentPolicyPojos(deploymentPolicies);
-    }
-
-    public static org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy[]
-    getDeploymentPolicies (String cartridgeType) throws RestAPIException {
-
-        DeploymentPolicy [] deploymentPolicies = null;
-        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
-        if (autoscalerServiceClient != null) {
-            try {
-                deploymentPolicies = autoscalerServiceClient.getDeploymentPolicies(cartridgeType);
-
-            } catch (RemoteException e) {
-                String errorMsg = "Error while getting available deployment policies for cartridge type " +
-                        cartridgeType+". Cause: "+e.getMessage();;
-                log.error(errorMsg, e);
-                throw new RestAPIException(errorMsg, e);
-            }
-        }
-
-        if(deploymentPolicies.length == 0) {
-            String errorMsg = "Cannot find any matching deployment policy for Cartridge [type] "+cartridgeType;
-            log.error(errorMsg);
-            throw new RestAPIException(errorMsg);
-        }
-
-        return PojoConverter.populateDeploymentPolicyPojos(deploymentPolicies);
-    }
-
     public static org.apache.stratos.common.beans.autoscaler.policy.deployment.DeploymentPolicy
     getDeploymentPolicy(String deploymentPolicyId) throws RestAPIException {
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/fbcf3847/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index c44b5b0..c8ab6a1 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -323,8 +323,56 @@ public class StratosApiV41 extends AbstractApi {
         return Response.noContent().build();
     }
 
-    // API methods for application deployments
-    
+    // API methods for applications
+
+    /**
+     * Add application
+     * @param applicationDefinition
+     * @return
+     * @throws RestAPIException
+     */
+    @POST
+    @Path("/applications")
+    @Produces("application/json")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/admin/manage/add/application")
+    public Response addApplication(ApplicationDefinition applicationDefinition)
+            throws RestAPIException {
+        StratosApiV41Utils.addApplication(applicationDefinition, getConfigContext(), getUsername(), getTenantDomain());
+        URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinition.getApplicationId()).build();
+        return Response.created(url).build();
+    }
+
+    /**
+     * Return applications
+     * @return
+     * @throws RestAPIException
+     */
+    @GET
+    @Path("/applications")
+    @Produces("application/json")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/admin/manage/list/applications")
+    public Response getApplications()
+            throws RestAPIException {
+        List<ApplicationDefinition> applicationDefinitions = StratosApiV41Utils.getApplications();
+        return Response.ok(applicationDefinitions).build();
+    }
+
+    @GET
+    @Path("/applications/{applicationId}")
+    @Produces("application/json")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/admin/manage/list/applications")
+    public Response getApplication(@PathParam("applicationId") String applicationId)
+            throws RestAPIException {
+        ApplicationDefinition applicationDefinition = StratosApiV41Utils.getApplication(applicationId);
+        if(applicationDefinition == null) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
+        return Response.ok(applicationDefinition).build();
+    }
+
     /**
      * Deploy application.
      *
@@ -333,14 +381,13 @@ public class StratosApiV41 extends AbstractApi {
      * @throws RestAPIException the rest api exception
      */
     @POST
-    @Path("/applicationDeployments")
+    @Path("/application/{applicationId}/deploy")
     @Produces("application/json")
     @Consumes("application/json")
-    @AuthorizationAction("/permission/admin/manage/add/deploymentPolicy")
-    public Response deployApplication(DeploymentPolicy deploymentPolicy)
+    @AuthorizationAction("/permission/admin/manage/deploy/application")
+    public Response deployApplication(@PathParam("applicationId") String applicationId, DeploymentPolicy deploymentPolicy)
             throws RestAPIException {
-        StratosApiV41Utils.deployApplication(deploymentPolicy);
-        //URI url = uriInfo.getAbsolutePathBuilder().path(policyId).build();
+        StratosApiV41Utils.deployApplication(applicationId, deploymentPolicy);
         return Response.accepted().build();
     }
     
@@ -352,7 +399,7 @@ public class StratosApiV41 extends AbstractApi {
      * @throws RestAPIException the rest api exception
      */
     @DELETE
-    @Path("/applicationDeployments/{applicationId}")
+    @Path("/applications/{applicationId}/undeploy")
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/admin/manage/add/deploymentPolicy")
@@ -361,24 +408,50 @@ public class StratosApiV41 extends AbstractApi {
         StratosApiV41Utils.undeployApplication(applicationId);
         return Response.accepted().build();
     }
-    
-    // API methods for deployment policies
 
     /**
-     * Gets the deployment policies.
+     * This API resource provides information about the application denoted by the given appId. Details includes,
+     * Application details, top level cluster details, details of the group and sub groups.
      *
-     * @return the deployment policies
-     * @throws RestAPIException the rest api exception
+     * @param applicationId Id of the application.
+     * @return Json representing the application details with 200 as HTTP status. HTTP 404 is returned when there is
+     * no application with given Id.
+     * @throws RestAPIException is thrown in case of failure occurs.
      */
     @GET
-    @Path("/deploymentPolicies")
+    @Path("/applications/{applicationId}/runtime")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/protected/manage/list/applicationRuntimes")
+    public Response getApplicationRuntime(@PathParam("applicationId") String applicationId) throws RestAPIException {
+        ApplicationBean applicationRuntime = StratosApiV41Utils.getApplicationRuntime(applicationId);
+        if (applicationRuntime == null) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        } else {
+            return Response.ok().entity(applicationRuntime).build();
+        }
+    }
+
+    /**
+     * Delete an application.
+     *
+     * @param applicationId the application id
+     * @return the response
+     * @throws RestAPIException the rest api exception
+     */
+    @DELETE
+    @Path("/applications/{applicationId}")
     @Produces("application/json")
     @Consumes("application/json")
-    @AuthorizationAction("/permission/admin/manage/view/deploymentPolicy")
-    public Response getDeploymentPolicies() throws RestAPIException {
-        return Response.ok().entity(StratosApiV41Utils.getDeploymentPolicies()).build();
+    @AuthorizationAction("/permission/protected/manage/delete/application")
+    @SuperTenantService(true)
+    public Response deleteApplication(@PathParam("applicationId") String applicationId)
+            throws RestAPIException {
+        StratosApiV41Utils.deleteApplication(applicationId);
+        return Response.noContent().build();
     }
 
+    // API methods for deployment policies
+
     /**
      * Gets a specific deployment policy.
      *
@@ -412,27 +485,6 @@ public class StratosApiV41 extends AbstractApi {
             throws RestAPIException {
         return Response.ok().entity(StratosApiV41Utils.getPartitionGroups(deploymentPolicyId)).build();
     }
-    
-//    @GET
-//    @Path("/deploymentPolicies/{deploymentPolicyId}/partitionGroup/{partitionGroupId}")
-//    @Produces("application/json")
-//    @Consumes("application/json")
-//    @AuthorizationAction("/permission/admin/manage/view/partition")
-//    public Response getPartitionGroupForDeploymentPolicy(@PathParam("deploymentPolicyId") String deploymentPolicyId,
-//                                      @PathParam("partitionGroupId") String partitionGroupId) throws RestAPIException {
-//        return Response.ok().entity(StratosApiV41Utils.getPartitionsOfGroup(deploymentPolicyId, partitionGroupId)).build();
-//    }
-
-//    @GET
-//    @Path("/deploymentPolicies/{deploymentPolicyId}/partition")
-//    @Produces("application/json")
-//    @Consumes("application/json")
-//    @AuthorizationAction("/permission/admin/manage/view/partition")
-//    public Response getPartitionsForDeploymentPolicy(@PathParam("deploymentPolicyId") String deploymentPolicyId)
-//            throws RestAPIException {
-//
-//        return Response.ok().entity(StratosApiV41Utils.getPartitionsOfDeploymentPolicy(deploymentPolicyId)).build();
-//    }
 
     // API methods for autoscaling policies
     
@@ -511,90 +563,6 @@ public class StratosApiV41 extends AbstractApi {
         return Response.ok().build();
     }
 
-    // API methods for applications
-       
-    /**
-     * Gets details of all the applications.
-     *
-     * @return the applications
-     * @throws RestAPIException the rest api exception
-     */
-    @GET
-    @Path("/applications")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response getApplications() throws RestAPIException {
-        ApplicationBean[] applications = StratosApiV41Utils.getApplications();
-        if (applications == null) {
-            return Response.status(Response.Status.NOT_FOUND).build();
-        } else {
-            return Response.ok().entity(applications).build();
-        }
-    }
-
-    /**
-     * This API resource provides information about the application denoted by the given appId. Details includes,
-     * Application details, top level cluster details, details of the group and sub groups.
-     *
-     * @param applicationId Id of the application.
-     * @return Json representing the application details with 200 as HTTP status. HTTP 404 is returned when there is
-     * no application with given Id.
-     * @throws RestAPIException is thrown in case of failure occurs.
-     */
-    @GET
-    @Path("/applications/{applicationId}")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response getApplication(@PathParam("applicationId") String applicationId) throws RestAPIException {
-        ApplicationBean application = StratosApiV41Utils.getApplication(applicationId);
-        if (application == null) {
-            return Response.status(Response.Status.NOT_FOUND).build();
-        } else {
-            return Response.ok().entity(application).build();
-        }
-    }
-    
-    /**
-     * Creates the application definition.
-     *
-     * @param applicationDefinitionBean the application definition bean
-     * @return the response
-     * @throws RestAPIException the rest api exception
-     */
-    @POST
-    @Path("/applications")
-    @Produces("application/json")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    @SuperTenantService(true)
-    public Response createApplicationDefinition(ApplicationDefinition applicationDefinitionBean)
-            throws RestAPIException {
-        StratosApiV41Utils.createApplicationDefinition(applicationDefinitionBean, getConfigContext(),
-                getUsername(), getTenantDomain());
-        URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinitionBean.getApplicationId()).build();
-        return Response.created(url).build();
-    }
-
-    /**
-	 * Removes the application definition.
-	 *
-	 * @param applicationId the application id
-	 * @return the response
-	 * @throws RestAPIException the rest api exception
-	 */
-	@DELETE
-    @Path("/applications/{applicationId}")
-    @Produces("application/json")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    @SuperTenantService(true)
-    public Response deleteApplicationDefinition(@PathParam("applicationId") String applicationId)
-            throws RestAPIException {
-		StratosApiV41Utils.removeApplicationDefinition(applicationId, getConfigContext(), getUsername(),
-                getTenantDomain());
-        return Response.noContent().build();
-    }
-    
     // API methods for subscriptions
 
     /**