Repository: stratos
Updated Branches:
  refs/heads/master 272027249 -> 484941816


modifying jaggery console app due to the changes in the back-end rest api

Signed-off-by: Akila Perera <[email protected]>


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

Branch: refs/heads/master
Commit: 4849418169266bc8e2ad4ced4828f2709556e77a
Parents: 2720272
Author: R-Rajkumar <[email protected]>
Authored: Mon Sep 1 11:04:58 2014 +0530
Committer: Akila Perera <[email protected]>
Committed: Mon Sep 1 12:23:04 2014 +0530

----------------------------------------------------------------------
 .../console/cartridge_info.jag                  |  18 ++-
 .../console/cartridge_info_sg.jag               |  29 ++--
 .../console/cartridges.jag                      |   5 +
 .../console/configure_stratos.jag               |  33 +++--
 .../console/configure_stratos_wizard.jag        |  38 +++--
 .../console/index.jag                           |   6 +-
 .../console/subscribe_cartridge.jag             |  24 +++-
 .../console/tenant_management.jag               |   5 +
 .../theme1/renderers/configure_stratos.js       |   6 +-
 .../renderers/configure_stratos_wizard.js       |   8 +-
 .../console/themes/theme1/renderers/index.js    |   3 +
 .../theme1/renderers/subscribe_cartridge.js     |  18 ++-
 .../theme1/renderers/tenant_management.js       |   6 +-
 .../console/util/utility.jag                    | 140 +++++++++++--------
 .../rest/endpoint/services/StratosAdmin.java    |   3 +-
 15 files changed, 234 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/cartridge_info.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/cartridge_info.jag 
b/components/org.apache.stratos.manager.console/console/cartridge_info.jag
index 653e31a..3b45af6 100644
--- a/components/org.apache.stratos.manager.console/console/cartridge_info.jag
+++ b/components/org.apache.stratos.manager.console/console/cartridge_info.jag
@@ -23,11 +23,15 @@ var caramel = require('caramel');
 var error = [];
 var utils = require('/util/utility.jag');
 var process = require('process');
- var log = new Log('utility.cartridgeInfo');
+var log = new Log('utility.cartridgeInfo');
 var alias = request.getParameter("alias");
 var lbCluster = {};
 var cartridgeInfo = utils.consoleAppUtil.getCartridgeInfo(alias);
 
+if(cartridgeInfo == null || cartridgeInfo == undefined || cartridgeInfo == ""){
+    cartridgeInfo = {};
+}
+
 if(cartridgeInfo.Error != undefined){
     error.push(cartridgeInfo.Error);
 }else{
@@ -43,11 +47,17 @@ if(cartridgeInfo.Error != undefined){
     }
     */
     lbCluster = utils.consoleAppUtil.getLBClusterInfo();
-            if(lbCluster.Error != undefined){
-                error.push(lbCluster.Error);
+    if(lbCluster == null || lbCluster == undefined || lbCluster == ""){
+        lbCluster = {};
     }
-
+    if(lbCluster.Error != undefined){
+        error.push(lbCluster.Error);
+    }
+    
     var clusterInfo = 
utils.consoleAppUtil.getClusterInfoWithAlias(cartridgeInfo.cartridge.cartridgeType,
 alias);
+    if(clusterInfo == null || clusterInfo == undefined || clusterInfo == ""){
+        clusterInfo = {};
+    }
     if(clusterInfo.Error != undefined){
         error.push(clusterInfo.Error);
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag 
b/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag
index 0d1c521..7c874f3 100644
--- 
a/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag
+++ 
b/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag
@@ -27,6 +27,10 @@ var process = require('process');
 var serviceGroup = request.getParameter("serviceGroup");
 //Get all alias for a service group
 var cartridges = utils.consoleAppUtil.getCartridgeServiceGroup(serviceGroup);
+
+if(cartridges == null || cartridges == undefined || cartridges == ""){
+    cartridges = {};
+}
 cartridges=cartridges.cartridge;
 
 if(cartridges.Error != undefined){
@@ -41,24 +45,31 @@ if(cartridges.Error != undefined){
         var alias = cartridges[i].cartridgeAlias;
         var lbCluster = {};
 
-           lbCluster = utils.consoleAppUtil.getLBClusterInfo();
-           if(lbCluster.Error != undefined){
-                error.push(lbCluster.Error);
-            }else{
-                //cartridges[i].lbClusterinfo = 
{member:[{memberIp:"foo"},{}]};//lbCluster.cluster;
-                //cartridges[i].lbClusterinfo = lbCluster.cluster[0];
-                cartridges[i].lbclusterinfo = lbCluster.cluster[0];
-            }
+        lbCluster = utils.consoleAppUtil.getLBClusterInfo();
+        if(lbCluster == null || lbCluster == undefined || lbCluster == ""){
+            lbCluster = {};
+        }
+        if(lbCluster.Error != undefined){
+            error.push(lbCluster.Error);
+        }else{
+            //cartridges[i].lbClusterinfo = 
{member:[{memberIp:"foo"},{}]};//lbCluster.cluster;
+            //cartridges[i].lbClusterinfo = lbCluster.cluster[0];
+            cartridges[i].lbclusterinfo = lbCluster.cluster[0];
+        }
+        
         //Getting the clusterInfo and putting it to the relevant cartridge json
         var clusterInfo = 
utils.consoleAppUtil.getClusterInfoWithAlias(cartridgeInfo.cartridgeType, 
alias);
+        if(clusterInfo == null || clusterInfo == undefined || clusterInfo == 
""){
+           clusterInfo = {};
+        }
         if(clusterInfo.Error != undefined){
             error.push(clusterInfo.Error);
         }else{
             cartridges[i].clusterInfo = clusterInfo.cluster[0];
         }
-
     }
 }
+
 var bamInfo 
={bamip:process.getProperty('bam.ip'),bamport:process.getProperty('bam.port')};
 caramel.render({
     cartridges:cartridges,

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/cartridges.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/cartridges.jag 
b/components/org.apache.stratos.manager.console/console/cartridges.jag
index 3060bc1..3403427 100644
--- a/components/org.apache.stratos.manager.console/console/cartridges.jag
+++ b/components/org.apache.stratos.manager.console/console/cartridges.jag
@@ -24,9 +24,14 @@ var error = [];
 var utils = require('/util/utility.jag');
 var process = require('process');
 var availableCartridges = utils.consoleAppUtil.getCartridges();
+
+if(availableCartridges == null || availableCartridges == undefined || 
availableCartridges == ""){
+   availableCartridges = {};
+}
 if(availableCartridges.Error != undefined){
     error.push(availableCartridges.Error);
 }
+
 var bamInfo 
={bamip:process.getProperty('bam.ip'),bamport:process.getProperty('bam.port')};
 caramel.render({
     cartridges:availableCartridges,

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/configure_stratos.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/configure_stratos.jag 
b/components/org.apache.stratos.manager.console/console/configure_stratos.jag
index 6e8435f..8718bbc 100644
--- 
a/components/org.apache.stratos.manager.console/console/configure_stratos.jag
+++ 
b/components/org.apache.stratos.manager.console/console/configure_stratos.jag
@@ -39,22 +39,29 @@ var config_status = utils.consoleAppUtil.getConfigStatus();
 
 if(wizard.step == 1){
     var step_data =  utils.consoleAppUtil.getPartitions();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
         step_data = step_data.partition;
     }
-
 }else if(wizard.step == 2){
     step_data =  utils.consoleAppUtil.getPolicyAutoScale();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
         step_data = step_data.autoscalePolicy;
     }
-
 }else if(wizard.step == 3){
     step_data =  utils.consoleAppUtil.getPolicyDeployment();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
@@ -62,6 +69,9 @@ if(wizard.step == 1){
     }
 }else if(wizard.step == 4){
     step_data =  utils.consoleAppUtil.getLbCartridges();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
@@ -69,25 +79,32 @@ if(wizard.step == 1){
     }
 }else if(wizard.step == 5){
     step_data =  utils.consoleAppUtil.getCartridges();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
         step_data = step_data.cartridge;
-        for(var i=0;i<step_data.length;i++) {
-            if(step_data[i].loadBalancer == true ) {
-                step_data.splice(i,1);
-                i = i - 1;
-            }
-        }
+           for(var i=0;i<step_data.length;i++) {
+               if(step_data[i].loadBalancer == true ) {
+                   step_data.splice(i,1);
+                   i = i - 1;
+               }
+           }
     }
 }else if(wizard.step == 6){
     step_data = utils.consoleAppUtil.getServices();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
         step_data = step_data.serviceDefinitionBean;
     }
 }
+
 caramel.render({
     step_data:step_data,
     wizard:wizard,

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/configure_stratos_wizard.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/configure_stratos_wizard.jag
 
b/components/org.apache.stratos.manager.console/console/configure_stratos_wizard.jag
index ac7f802..314b1a7 100644
--- 
a/components/org.apache.stratos.manager.console/console/configure_stratos_wizard.jag
+++ 
b/components/org.apache.stratos.manager.console/console/configure_stratos_wizard.jag
@@ -35,16 +35,21 @@ var wizard = {
 
 var utils = require('/util/utility.jag');
 
-
 if(wizard.step == 1){
     var step_data =  utils.consoleAppUtil.getPartitions();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
-    }else{
+    }else{ 
         step_data = step_data.partition;
-    }
+    }   
 }else if(wizard.step == 2){
     step_data =  utils.consoleAppUtil.getPolicyAutoScale();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
@@ -52,6 +57,9 @@ if(wizard.step == 1){
     }
 }else if(wizard.step == 3){
     step_data =  utils.consoleAppUtil.getPolicyDeployment();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
@@ -59,32 +67,42 @@ if(wizard.step == 1){
     }
 }else if(wizard.step == 4){
     step_data =  utils.consoleAppUtil.getLbCartridges();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
         step_data = step_data.cartridge;
     }
-}else if(wizard.step == 5){
+ }else if(wizard.step == 5){
     step_data =  utils.consoleAppUtil.getCartridges();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
         step_data = step_data.cartridge;
-        for(var i=0;i<step_data.length;i++) {
-            if(step_data[i].loadBalancer == true ) {
-                step_data.splice(i,1);
-                i = i - 1;
-            }
-        }
+           for(var i=0;i<step_data.length;i++) {
+               if(step_data[i].loadBalancer == true ) {
+                   step_data.splice(i,1);
+                   i = i - 1;
+               }
+          }
     }
 }else if(wizard.step == 6){
     step_data = utils.consoleAppUtil.getServices();
+    if(step_data == null || step_data == undefined || step_data == ""){
+        step_data = {};
+    }
     if(step_data.Error != undefined){
         error.push(step_data.Error);
     }else{
         step_data = step_data.serviceDefinitionBean;
     }
 }
+
 var bamInfo 
={bamip:process.getProperty('bam.ip'),bamport:process.getProperty('bam.port')};
 caramel.render({
     step_data:step_data,

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/index.jag
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/index.jag 
b/components/org.apache.stratos.manager.console/console/index.jag
index e99bcd1..368bade 100644
--- a/components/org.apache.stratos.manager.console/console/index.jag
+++ b/components/org.apache.stratos.manager.console/console/index.jag
@@ -27,6 +27,10 @@ var process = require('process');
 
 var subscribedCartridges =  utils.consoleAppUtil.getSubscribedCartridges();
 
+if(subscribedCartridges == null || subscribedCartridges == undefined || 
subscribedCartridges == ""){
+    subscribedCartridges = {};
+}
+
 var errorInSession = session.get("errorinbackend");
 if(errorInSession != undefined) {
    session.remove("errorinbackend");
@@ -34,7 +38,7 @@ if(errorInSession != undefined) {
 }
 
 if(subscribedCartridges.Error != undefined){
-    error.push(subscribedCartridges.Error);
+   error.push(subscribedCartridges.Error);
 }
 
 var bamInfo 
={bamip:process.getProperty('bam.ip'),bamport:process.getProperty('bam.port')};

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/subscribe_cartridge.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/subscribe_cartridge.jag 
b/components/org.apache.stratos.manager.console/console/subscribe_cartridge.jag
index c73208b..b0b06c2 100644
--- 
a/components/org.apache.stratos.manager.console/console/subscribe_cartridge.jag
+++ 
b/components/org.apache.stratos.manager.console/console/subscribe_cartridge.jag
@@ -30,13 +30,31 @@ var deploymentPolicies = 
utils.consoleAppUtil.getApplicableDeploymentPolicies(ty
 var mtServiceInfo = utils.consoleAppUtil.getServiceInfo(type);
 var cartridge = utils.consoleAppUtil.getSingleTenantCartridgeInfo(type);
 
+if(autoScalePolicies == null || autoScalePolicies == undefined || 
autoScalePolicies == ""){
+    autoScalePolicies = {};
+}
 if(autoScalePolicies.Error != undefined ){
     error.push(autoScalePolicies.Error);
-}if(deploymentPolicies.Error != undefined ){
+}
+
+if(deploymentPolicies == null || deploymentPolicies == undefined || 
deploymentPolicies == ""){
+    deploymentPolicies = {};
+}
+if(deploymentPolicies.Error != undefined ){
     error.push(deploymentPolicies.Error);
-}if(cartridge.Error != undefined ){
+}
+
+if(cartridge == null || cartridge == undefined || cartridge == ""){
+    cartridge = {};
+}
+if(cartridge.Error != undefined ){
     error.push(cartridge.Error);
-}if(mtServiceInfo.Error != undefined ){
+}
+
+if(mtServiceInfo == null || mtServiceInfo == undefined || mtServiceInfo == ""){
+    mtServiceInfo = {};
+}
+if(mtServiceInfo.Error != undefined ){
     error.push(mtServiceInfo.Error);
 }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/tenant_management.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/tenant_management.jag 
b/components/org.apache.stratos.manager.console/console/tenant_management.jag
index f805717..df20752 100644
--- 
a/components/org.apache.stratos.manager.console/console/tenant_management.jag
+++ 
b/components/org.apache.stratos.manager.console/console/tenant_management.jag
@@ -25,9 +25,14 @@ var error = [];
 var utils = require('/util/utility.jag');
 var process = require('process');
 var tenants =  utils.consoleAppUtil.getTenants();
+
+if(tenants == null || tenants == undefined || tenants == ""){
+    tenants = {};
+}
 if(tenants.Error != undefined){
     error.push(tenants.Error);
 }
+
 var bamInfo 
={bamip:process.getProperty('bam.ip'),bamport:process.getProperty('bam.port')};
 caramel.render({
     tenants:tenants,

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos.js
 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos.js
index 46aab9f..d258013 100755
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos.js
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos.js
@@ -89,8 +89,10 @@ var render = function (theme, data, meta, require) {
     session.remove("get-status");
     session.remove("deploy-status");
 
-    for(var i=0;i<step_data.length;i++){
-        step_data[i].json_string = stringify(step_data[i]);
+    if(step_data != null && step_data != undefined){
+      for(var i=0;i<step_data.length;i++){
+          step_data[i].json_string = stringify(step_data[i]);
+      }
     }
     var log = new Log();
     theme('index', {

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos_wizard.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos_wizard.js
 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos_wizard.js
index 2c2d4c6..804c6df 100755
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos_wizard.js
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/configure_stratos_wizard.js
@@ -87,9 +87,13 @@ var render = function (theme, data, meta, require) {
     }else{
         title = 'Configure Stratos Wizard Finished';
     }
-    for(var i=0;i<step_data.length;i++){
-        step_data[i].json_string = stringify(step_data[i]);
+    
+    if(step_data != null && step_data != undefined){
+      for(var i=0;i<step_data.length;i++){
+          step_data[i].json_string = stringify(step_data[i]);
+      }
     }
+
     theme('index', {
         body: [
             {

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
index 47aaf53..fa6e688 100755
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/index.js
@@ -23,6 +23,9 @@ var render = function (theme, data, meta, require) {
       // Re-create the data structure of the cartridges.
     var log = new Log();
     if(data.error.length == 0 ){
+        if(data.mycartridges == null || data.mycartridges == undefined || 
data.mycartridges == ""){
+          data.mycartridges = {};
+        }
         var cartridges= data.mycartridges.cartridge,cartridges_new =[];
         session.remove("get-status");
         session.remove("deploy-status");

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/subscribe_cartridge.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/subscribe_cartridge.js
 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/subscribe_cartridge.js
index 92ec3f3..04270a5 100755
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/subscribe_cartridge.js
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/subscribe_cartridge.js
@@ -25,14 +25,26 @@ var render = function (theme, data, meta, require) {
         if(cartridge == undefined){
             cartridge = data.cartridge;
         }
+        var mtServiceInfo = {}
+        if(data.mtServiceInfo != null || data.mtServiceInfo != undefined && 
data.mtServiceInfo != ""){
+            mtServiceInfo = data.mtServiceInfo.serviceDefinitionBean;
+        }
+        var autoScalePolicies = {}
+        if(data.autoScalePolicies != null && data.autoScalePolicies != 
undefined && data.autoScalePolicies != ""){
+            autoScalePolicies = data.autoScalePolicies.autoscalePolicy;
+        }
+        var deploymentPolicies = {}
+        if(data.deploymentPolicies != null && data.deploymentPolicies != 
undefined && data.deploymentPolicies != ""){
+            deploymentPolicies = data.deploymentPolicies.deploymentPolicy;     
+        } 
         theme('index', {
             body: [
                 {
                     partial: 'subscribe_cartridge',
                     context: {
-                        
autoScalePolicies:data.autoScalePolicies.autoscalePolicy,
-                        
deploymentPolicies:data.deploymentPolicies.deploymentPolicy,
-                        mtServiceInfo:data.mtServiceInfo.serviceDefinitionBean,
+                        autoScalePolicies:autoScalePolicies,
+                        deploymentPolicies:deploymentPolicies,
+                        mtServiceInfo:mtServiceInfo,
                         cartridge:cartridge,
                         
cartridgeType:meta.request.getParameter('cartridgeType'),
                         serviceGroup:meta.request.getParameter('serviceGroup')

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/tenant_management.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/tenant_management.js
 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/tenant_management.js
index 7be977a..34d2017 100755
--- 
a/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/tenant_management.js
+++ 
b/components/org.apache.stratos.manager.console/console/themes/theme1/renderers/tenant_management.js
@@ -84,12 +84,8 @@ var render = function (theme, data, meta, require) {
                             name: 'Subscribe to Cartridge',
                             class_name: 'btn-important'
                         },
-<<<<<<< HEAD
-                        has_help:false,
-=======
                         bamInfo:data.bamInfo,
-                        has_help: true,
->>>>>>> 400
+                        has_help: false,
                         help: 'Create cartridges like PHP, Python, Ruby etc.. 
Or create data cartridges with mySql, PostgreSQL. Directly install applications 
like Drupal, Wordpress etc..'
                     }
                 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.manager.console/console/util/utility.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/util/utility.jag 
b/components/org.apache.stratos.manager.console/console/util/utility.jag
index 3cd93eb..083b330 100644
--- a/components/org.apache.stratos.manager.console/console/util/utility.jag
+++ b/components/org.apache.stratos.manager.console/console/util/utility.jag
@@ -98,150 +98,150 @@ consoleAppUtil = new function(){
     var log = new Log('utility.consoleAppUtil');
 
     this.getAvailableSingleTenantCartridges = function(){
-        return this.sendReceive("GET","/cartridge/list",{}).data;
+        return this.sendReceive("GET","/cartridge/list",{});
     };
 
     this.getAvailableMultiTenantCartridges = function(){
-        return this.sendReceive("GET","/cartridge/tenanted/list",{}).data;
+        return this.sendReceive("GET","/cartridge/tenanted/list",{});
     };
 
     this.getSubscribedCartridges = function(){
-        return this.sendReceive("GET","/cartridge/list/subscribed",{}).data;
+        return this.sendReceive("GET","/cartridge/list/subscribed",{});
     }
 
     this.getTenants = function(){
-        return this.sendReceive("GET","/tenant/list",{}).data;
+        return this.sendReceive("GET","/tenant/list",{});
     };
 
     this.getServices = function(){
-        return this.sendReceive("GET","/service",{}).data;
+        return this.sendReceive("GET","/service",{});
     };
 
     this.deployCartridgeDefinition = function(cartridgeDefinition){
-        return 
this.send("POST","/cartridge/definition",cartridgeDefinition).data;
+        return this.send("POST","/cartridge/definition",cartridgeDefinition);
     };
 
     this.deployServiceDefinition = function(serviceDefinition){
-        return this.send("POST","/service/definition",serviceDefinition).data;
+        return this.send("POST","/service/definition",serviceDefinition);
     };
 
     this.deployLbDefinition = function(lbDefinition){
-        return this.send("POST","/cartridge/definition",lbDefinition).data;
+        return this.send("POST","/cartridge/definition",lbDefinition);
     };
 
     this.activateTenant = function(tenantDomain){
-            return this.send("POST","/tenant/activate/" + 
tenantDomain,{}).data;
+            return this.send("POST","/tenant/activate/" + tenantDomain,{});
             };
 
     this.deactivateTenant = function(tenantDomain){
-        return this.send("POST","/tenant/deactivate/" + tenantDomain,{}).data;
+        return this.send("POST","/tenant/deactivate/" + tenantDomain,{});
     };
 
     this.deleteTenant = function(tenantDomain){
-        return this.send("DELETE","/tenant/" + tenantDomain,{}).data;
+        return this.send("DELETE","/tenant/" + tenantDomain,{});
     };
 
     this.checkAvailability = function(tenantDomain){
-        return this.send("POST","/tenant/availability/" + 
tenantDomain,{}).data;
+        return this.send("POST","/tenant/availability/" + tenantDomain,{});
     };
 
     this.deployPartitionDefinition = function(partitionDefinition){
-        return 
this.send("POST","/policy/deployment/partition",partitionDefinition).data;
+        return 
this.send("POST","/policy/deployment/partition",partitionDefinition);
     };
 
     this.deployDeploymentPolicyDefinition = function(policyDefinition){
-        return this.send("POST","/policy/deployment",policyDefinition).data;
+        return this.send("POST","/policy/deployment",policyDefinition);
     };
 
     this.deployAutoscalePolicyDefinition = function(policyDefinition){
-        return this.send("POST","/policy/autoscale",policyDefinition).data;
+        return this.send("POST","/policy/autoscale",policyDefinition);
     };
 
 
     this.subscribeToCartridge = function(cartridgeBeanInfo){
-        return this.sendReceive("POST","/cartridge/subscribe", 
cartridgeBeanInfo).data;
+        return this.sendReceive("POST","/cartridge/subscribe", 
cartridgeBeanInfo);
     };
 
     this.addTenant = function(tenantInfoBean){
-        return this.sendReceive("POST","/tenant",tenantInfoBean).data;
+        return this.sendReceive("POST","/tenant",tenantInfoBean);
     };
 
     this.syncRepo = function(alias){
-        return this.send("POST","/cartridge/sync",alias).data;
+        return this.send("POST","/cartridge/sync",alias);
     };
 
     this.getAutoScalePolicies = function(){
-        return this.sendReceive("GET","/policy/autoscale",{}).data;
+        return this.sendReceive("GET","/policy/autoscale",{});
     };
 
     this.getDeploymentPolicies = function(){
-        return this.sendReceive("GET","/policy/deployment",{}).data;
+        return this.sendReceive("GET","/policy/deployment",{});
     };
 
     this.getApplicableDeploymentPolicies = function(cartridgeType){
-     return this.sendReceive("GET","/" + cartridgeType + 
"/policy/deployment/",{}).data;
+     return this.sendReceive("GET","/" + cartridgeType + 
"/policy/deployment/",{});
    };
 
     this.getPartitions = function(){
-        return this.sendReceive("GET","/partition",{}).data;
+        return this.sendReceive("GET","/partition",{});
     };
 
     this.getSingleTenantCartridgeInfo = function(cartridgeType){
-        return this.sendReceive("GET","/cartridge/available/info/" + 
cartridgeType,{}).data;
+        return this.sendReceive("GET","/cartridge/available/info/" + 
cartridgeType,{});
     };
 
     this.getServiceInfo = function(cartridgeType){
-        return this.sendReceive("GET","/service/" + cartridgeType,{}).data;
+        return this.sendReceive("GET","/service/" + cartridgeType,{});
     };
 
     this.getPolicyAutoScale = function(){
-        return this.sendReceive("GET","/policy/autoscale",{}).data;
+        return this.sendReceive("GET","/policy/autoscale",{});
     };
 
     this.getPolicyDeployment = function(){
-        return this.sendReceive("GET","/policy/deployment",{}).data;
+        return this.sendReceive("GET","/policy/deployment",{});
     };
     this.unsubscribeCartridge = function(alias){
-        return this.send("POST","/cartridge/unsubscribe",alias).data;
+        return this.send("POST","/cartridge/unsubscribe",alias);
     };
     this.getCartridges = function(){
-        return this.sendReceive("GET","/cartridge/available/list",{}).data;
+        return this.sendReceive("GET","/cartridge/available/list",{});
     };
 
     this.getLbCartridges = function(){
-        return this.sendReceive("GET","/cartridge/lb",{}).data;
+        return this.sendReceive("GET","/cartridge/lb",{});
     };
 
     this.getClusterInfo = function(clusterId){
-        return this.sendReceive("GET","/cluster/clusterId/" + 
clusterId,{}).data;
+        return this.sendReceive("GET","/cluster/clusterId/" + clusterId,{});
     };
 
     this.getLBClusterInfo = function(){
-        return this.sendReceive("GET","/cluster/lb",{}).data;
+        return this.sendReceive("GET","/cluster/lb",{});
     };
 
     this.getClusterInfoWithAlias = function(cartridgeType, alias){
-        return this.sendReceive("GET","/cluster/" + cartridgeType + "/" + 
alias,{}).data;
+        return this.sendReceive("GET","/cluster/" + cartridgeType + "/" + 
alias,{});
     };
     this.getCartridgeInfo = function(alias){
-        return this.sendReceive("GET","/cartridge/info/"+alias,{}).data;
+        return this.sendReceive("GET","/cartridge/info/"+alias,{});
     };
     this.getCartridgeServiceGroup = function(serviceGroup){
-        return 
this.sendReceive("GET","/cartridge/list/subscribed/group/"+serviceGroup,{}).data;
+        return 
this.sendReceive("GET","/cartridge/list/subscribed/group/"+serviceGroup,{});
     };
     this.validateCaptcha = function(captchaText){
-        return this.sendReceive("POST","/captcha",captchaText).data;
+        return this.sendReceive("POST","/captcha",captchaText);
     };
     this.getCaptcha = function(){
         return this.sendReceiveImage("Get","/simpleImg",{});
     };
     this.undeployCartridge = function(cartridgeType){
-        return 
this.sendReceive("DELETE","/cartridge/definition/"+cartridgeType,{}).data;
+        return 
this.sendReceive("DELETE","/cartridge/definition/"+cartridgeType,{});
     };
     this.getConfigStatus = function(){
         var configStatus = {};
         var error;
-        var par_res = this.sendReceive("GET","/partition",{}).data;
+        var par_res = this.sendReceive("GET","/partition",{});
         var get_status = session.get("get-status");
         if(par_res.Error != undefined){
             error = par_res.Error;
@@ -251,7 +251,7 @@ consoleAppUtil = new function(){
                 if(par_res.partition.length == 0){
                     configStatus.first_use = true;
                 }else{
-                    var car_res = 
this.sendReceive("GET","/cartridge/available/list",{}).data;
+                    var car_res = 
this.sendReceive("GET","/cartridge/available/list",{});
                     if(car_res.Error != undefined){
                         error=car_res.Error;
                         configStatus.first_use = false;
@@ -301,33 +301,43 @@ consoleAppUtil = new function(){
         // getting the access token from the session.
         var endpoint = backendServerURL + urlPostFix;
         var headers = this.getRequestHeaders(config.ssoConfiguration.enabled);
-        var type = "json"; // response format
         var response;
         switch (httpMethod){
             case  "GET":
-                response = get(endpoint,{},headers,type);
+                response = get(endpoint,{},headers);
                 break;
             case   "POST":
-                response = post(endpoint,stringify(data),headers,type);
+                response = post(endpoint,stringify(data),headers);
                 break;
             case    "PUT":
-                response = put(endpoint,stringify(data),headers,type);
+                response = put(endpoint,stringify(data),headers);
                 break;
             case    "DELETE":
-                response = del(endpoint,stringify(data),headers,type);
+                response = del(endpoint,stringify(data),headers);
                 break;
             default :
                 log.error("Error in the programme flow.");
         }
-        log.debug("-----------------------:" + stringify(response));
-        if(response.data.Error) {
-            session.put("get-status", response.data.Error.errorMessage);
-        } else {
-            session.put("get-status", "succeeded");
+        
+        if (response.xhr.status >= 200 && response.xhr.status < 300) { //if 
success
+           session.put("get-status", "succeeded");
+        } else if (response.xhr.status >= 400 && response.xhr.status < 500) { 
//if client error
+           if(response.data != null && response.data != undefined) {
+               session.put("get-status", 
parse(response.data).Error.errorMessage);
+           }
+        } else if (response.xhr.status >= 500 && response.xhr.status < 600) { 
//if server error
+           if(response.data != null && response.data != undefined) {
+               session.put("get-status", response.data); return;
+           }
         }
 
-        log.debug("--------------------:    +  " + urlPostFix + "      "+ 
session.get("get-status"));
-        return response;
+        log.debug("sent is: " + stringify(response));
+
+        if (response.data != null && response.data != undefined) {
+            return parse(response.data);
+        } else {
+            return response.data;
+        }
     };
 
     // refactor sendRecive and send method. duplicate code...
@@ -365,33 +375,43 @@ consoleAppUtil = new function(){
         // getting the access token from the session.
         var endpoint = backendServerURL + urlPostFix;
         var headers = this.getRequestHeaders(config.ssoConfiguration.enabled);
-        var type = "json"; // response format
         var response;
         switch (httpMethod){
             case  "GET":
-                response = get(endpoint,{},headers, 'json');
+                response = get(endpoint,{},headers);
                 break;
             case   "POST":
-                response = post(endpoint,data,headers, 'json');
+                response = post(endpoint,data,headers);
                 break;
             case    "PUT":
-                response = put(endpoint,data,headers, 'json');
+                response = put(endpoint,data,headers);
                 break;
             case    "DELETE":
-                response = del(endpoint,data,headers, 'json');
+                response = del(endpoint,data,headers);
                 break;
             default :
                 log.error("Error in the programme flow.");
         }
 
-        if (response.data.Error) {
-            session.put("deploy-status", response.data.Error.errorMessage);
-        } else {
-            session.put("deploy-status", "succeeded");
+        if (response.xhr.status >= 200 && response.xhr.status < 300) { //if 
success
+           session.put("deploy-status", "succeeded");
+        } else if (response.xhr.status >= 400 && response.xhr.status < 500) { 
//if client error
+           if(response.data != null && response.data != undefined) {
+               session.put("deploy-status", 
parse(response.data).Error.errorMessage);
+           }
+        } else if (response.xhr.status >= 500 && response.xhr.status < 600) { 
//if server error
+           if(response.data != null && response.data != undefined) {         
+               session.put("deploy-status", response.data); return;            
 
+           }
         }
+        
         log.debug("sent is: " + stringify(response));
 
-        return response;
+        if (response.data != null && response.data != undefined) {
+            return parse(response.data);
+        } else {
+            return response.data;
+        }
     };
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/48494181/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
 
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index fa5057d..f8c9f2f 100644
--- 
a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ 
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -377,7 +377,8 @@ public class StratosAdmin extends AbstractAdmin {
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")
     public Response getAvailableLbCartridges() throws RestAPIException {
-        return 
Response.ok().entity(ServiceUtils.getAvailableLbCartridges(false, 
getConfigContext())).build();
+       List<Cartridge> lbCartridges = 
ServiceUtils.getAvailableLbCartridges(false, getConfigContext());
+        return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] 
: lbCartridges.toArray(new Cartridge[lbCartridges.size()])).build();
     }
 
     @GET

Reply via email to