You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ch...@apache.org on 2015/04/14 01:01:44 UTC

[1/3] stratos git commit: Minor refactoring in REST API and CC client

Repository: stratos
Updated Branches:
  refs/heads/master 169909a57 -> 57099f61d


Minor refactoring in REST API and CC client


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

Branch: refs/heads/master
Commit: cbc1b3751251488bd59fc7c79eb12d6fca0cd83d
Parents: 169909a
Author: Chamila de Alwis <ch...@apache.org>
Authored: Mon Apr 13 23:24:17 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Mon Apr 13 23:24:25 2015 +0530

----------------------------------------------------------------------
 .../controller/services/impl/CloudControllerServiceImpl.java  | 7 ++++---
 .../stratos/common/client/CloudControllerServiceClient.java   | 2 +-
 .../apache/stratos/rest/endpoint/api/StratosApiV41Utils.java  | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/cbc1b375/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index 2f5c8c9..2a07199 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -1377,10 +1377,11 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 
             try {
                 KubernetesCluster kubernetesClusterStored = CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesHost.getHostId());
-                for (int i = 0; i < kubernetesClusterStored.getKubernetesHosts().length; i++) {
-                    if (kubernetesClusterStored.getKubernetesHosts()[i].getHostId().equals(kubernetesHost.getHostId())) {
+                KubernetesHost[] kubernetesHosts = kubernetesClusterStored.getKubernetesHosts();
+                for (int i = 0; i < kubernetesHosts.length; i++) {
+                    if (kubernetesHosts[i].getHostId().equals(kubernetesHost.getHostId())) {
                         // Update the information model
-                        kubernetesClusterStored.getKubernetesHosts()[i] = kubernetesHost;
+                        kubernetesHosts[i] = kubernetesHost;
 
                         if (log.isInfoEnabled()) {
                             log.info(String.format("Kubernetes host updated successfully: [id] %s", kubernetesHost.getHostId()));

http://git-wip-us.apache.org/repos/asf/stratos/blob/cbc1b375/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
index 313775f..cb19041 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
@@ -164,7 +164,7 @@ public class CloudControllerServiceClient {
         return stub.addKubernetesCluster(kubernetesCluster);
     }
 
-    public boolean deployKubernetesHost(String kubernetesClusterId, KubernetesHost kubernetesHost)
+    public boolean addKubernetesHost(String kubernetesClusterId, KubernetesHost kubernetesHost)
             throws RemoteException, CloudControllerServiceInvalidKubernetesHostExceptionException,
             CloudControllerServiceNonExistingKubernetesClusterExceptionException {
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/cbc1b375/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 c716bd7..225382b 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
@@ -1504,7 +1504,7 @@ public class StratosApiV41Utils {
                     ObjectConverter.convertKubernetesHostToStubKubernetesHost(kubernetesHostBean);
 
             try {
-                return cloudControllerServiceClient.deployKubernetesHost(kubernetesClusterId, kubernetesHost);
+                return cloudControllerServiceClient.addKubernetesHost(kubernetesClusterId, kubernetesHost);
             } catch (RemoteException e) {
                 log.error(e.getMessage(), e);
                 throw new RestAPIException(e.getMessage(), e);


[3/3] stratos git commit: Fixed code inspection warnings for API class and util class

Posted by ch...@apache.org.
Fixed code inspection warnings for API class and util class


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

Branch: refs/heads/master
Commit: 57099f61dc20d8a33cac8f4d13cce6987e5a2ee9
Parents: d42e63e
Author: Chamila de Alwis <ch...@apache.org>
Authored: Tue Apr 14 04:30:40 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Tue Apr 14 04:30:40 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41.java        |  38 +--
 .../rest/endpoint/api/StratosApiV41Utils.java   | 242 ++++++++++++-------
 2 files changed, 167 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/57099f61/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 3b1287d..8b931d3 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
@@ -312,7 +312,7 @@ public class StratosApiV41 extends AbstractApi {
 
     /**
      * Gets a single cartridge by type
-     * @param cartridgeType
+     * @param cartridgeType Cartridge type
      * @return 200 if specified cartridge exists, 404 if not
      * @throws RestAPIException
      */
@@ -333,8 +333,8 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Returns cartridges by category.
      *
-     * @param filter
-     * @param criteria
+     * @param filter Filter
+     * @param criteria Criteria
      * @return 200 if cartridges are found for specified filter, 404 if none found
      * @throws RestAPIException
      */
@@ -360,8 +360,8 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Returns a specific cartridge by category.
      *
-     * @param filter
-     * @param cartridgeType
+     * @param filter Filter
+     * @param cartridgeType Cartridge Type
      * @return 200 if a cartridge is found for specified filter, 404 if none found
      * @throws RestAPIException
      */
@@ -500,7 +500,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Add network partition
      *
-     * @param networkPartitionBean
+     * @param networkPartitionBean Network Partition
      * @return 201 if network partition successfully added, 409 if network partition already exists
      * @throws RestAPIException
      */
@@ -588,7 +588,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Add application
      *
-     * @param applicationDefinition
+     * @param applicationDefinition Application Definition
      * @return 201 if application is successfully added
      * @throws RestAPIException
      */
@@ -648,7 +648,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Deploy application.
      *
-     * @param applicationId
+     * @param applicationId Application Id
      * @param applicationPolicyId the application policy id
      * @return 202 after deployment process is started. Deployment is asynchronous
      * @throws RestAPIException the rest api exception
@@ -668,7 +668,7 @@ public class StratosApiV41 extends AbstractApi {
 
     /**
      * Adds an application policy
-     * @param applicationPolicy
+     * @param applicationPolicy Application Policy
      * @return 201 if the application policy is successfully added
      * @throws RestAPIException
      */
@@ -689,7 +689,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Retrieve specified application policy
      *
-     * @param applicationPolicyId
+     * @param applicationPolicyId Application Policy Id
      * @return 200 if application policy is found
      * @throws RestAPIException
      */
@@ -723,7 +723,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Remove specified application policy
      *
-     * @param applicationPolicyId
+     * @param applicationPolicyId Application Policy Id
      * @return 200 if application policy is successfully removed
      * @throws RestAPIException
      */
@@ -744,7 +744,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Update application policy
      *
-     * @param applicationPolicy
+     * @param applicationPolicy Application Policy
      * @return 200 if application policies successfully updated
      * @throws RestAPIException
      */
@@ -844,7 +844,7 @@ public class StratosApiV41 extends AbstractApi {
      * Adds the domain mappings for an application.
      *
      * @param applicationId       the application id
-     * @param domainMapppingsBean the domain mapppings bean
+     * @param domainMappingsBean the domain mappings bean
      * @return 200
      * @throws RestAPIException the rest api exception
      */
@@ -854,10 +854,10 @@ public class StratosApiV41 extends AbstractApi {
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/addDomainMappings")
     public Response addDomainMappings(
-            @PathParam("applicationId") String applicationId, ApplicationDomainMappingsBean domainMapppingsBean)
+            @PathParam("applicationId") String applicationId, ApplicationDomainMappingsBean domainMappingsBean)
             throws RestAPIException {
-        StratosApiV41Utils.addApplicationDomainMappings(applicationId, domainMapppingsBean);
-        List<DomainMappingBean> mappings = domainMapppingsBean.getDomainMappings();
+        StratosApiV41Utils.addApplicationDomainMappings(applicationId, domainMappingsBean);
+        List<DomainMappingBean> mappings = domainMappingsBean.getDomainMappings();
         List<String> domainMappingList = new ArrayList<String>();
         for (DomainMappingBean domainMappingBean : mappings) {
             domainMappingList.add(domainMappingBean.getDomainName());
@@ -1083,7 +1083,7 @@ public class StratosApiV41 extends AbstractApi {
 
     /**
      * Updates a network partition
-     * @param networkPartition
+     * @param networkPartition Network Partition
      * @return 200 if network partition is successfully updated
      * @throws RestAPIException
      */
@@ -1199,7 +1199,7 @@ public class StratosApiV41 extends AbstractApi {
                 .initializeTenant(ObjectConverter.convertTenantInfoBeanToCarbonTenantInfoBean(tenantInfoBean));
         TenantPersistor persistor = ServiceHolder.getTenantPersistor();
         // not validating the domain ownership, since created by super tenant
-        int tenantId = 0; //TODO verify whether this is the correct approach (isSkeleton)
+        int tenantId; //TODO verify whether this is the correct approach (isSkeleton)
         try {
             tenantId = persistor
                     .persistTenant(tenant, false, tenantInfoBean.getSuccessKey(), tenantInfoBean.getOriginatedService(),
@@ -1680,7 +1680,7 @@ public class StratosApiV41 extends AbstractApi {
 
     /**
      * Notify artifact update event for specified repository
-     * @param payload
+     * @param payload Git notification Payload
      * @return 204
      * @throws RestAPIException
      */

http://git-wip-us.apache.org/repos/asf/stratos/blob/57099f61/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 9b05ccb..7c81b91 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
@@ -77,12 +77,6 @@ import java.util.regex.Pattern;
 
 
 public class StratosApiV41Utils {
-    public static final String IS_VOLUME_REQUIRED = "volume.required";
-    public static final String SHOULD_DELETE_VOLUME = "volume.delete.on.unsubscription";
-    public static final String VOLUME_SIZE = "volume.size.gb";
-    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";
     public static final String APPLICATION_STATUS_CREATED = "Created";
 
@@ -101,7 +95,9 @@ public class StratosApiV41Utils {
             cloudControllerServiceClient.addCartridge(cartridgeConfig);
 
             if (log.isDebugEnabled()) {
-                log.debug(String.format("Successfully added cartridge: [cartridge-type] %s ", cartridgeDefinition.getType()));
+                log.debug(String.format(
+                        "Successfully added cartridge: [cartridge-type] %s ",
+                        cartridgeDefinition.getType()));
             }
         } catch (Exception e) {
             String msg = "Could not add cartridge";
@@ -166,7 +162,8 @@ public class StratosApiV41Utils {
 
             // Validate whether cartridge can be removed
             if (!smServiceClient.canCartridgeBeRemoved(cartridgeType)) {
-                String message = "Cannot remove cartridge : [cartridge-type] " + cartridgeType + " since it is used in another cartridge group or an application";
+                String message = "Cannot remove cartridge : [cartridge-type] " + cartridgeType +
+                        " since it is used in another cartridge group or an application";
                 log.error(message);
                 throw new RestAPIException(message);
             }
@@ -182,8 +179,8 @@ public class StratosApiV41Utils {
         }
     }
 
-    public static List<CartridgeBean> getCartridgesByFilter(String filter, String criteria, ConfigurationContext configurationContext)
-            throws RestAPIException {
+    public static List<CartridgeBean> getCartridgesByFilter(
+            String filter, String criteria, ConfigurationContext configurationContext) throws RestAPIException {
         List<CartridgeBean> cartridges = null;
 
         if (filter.equals("singleTenant")) {
@@ -193,14 +190,14 @@ public class StratosApiV41Utils {
         } else if (filter.equals("loadBalancer")) {
             cartridges = getAvailableLbCartridges(false, configurationContext);
         } else if (filter.equals("provider")) {
-            cartridges = getAvailableCartridgesByProvider(criteria, configurationContext);
+            cartridges = getAvailableCartridgesByProvider(criteria);
         }
 
         return cartridges;
     }
 
-    public static CartridgeBean getCartridgeByFilter(String filter, String cartridgeType, ConfigurationContext configurationContext)
-            throws RestAPIException {
+    public static CartridgeBean getCartridgeByFilter(
+            String filter, String cartridgeType, ConfigurationContext configurationContext) throws RestAPIException {
         List<CartridgeBean> cartridges = getCartridgesByFilter(filter, null, configurationContext);
 
         for (CartridgeBean cartridge : cartridges) {
@@ -213,8 +210,8 @@ public class StratosApiV41Utils {
         throw new RestAPIException(msg);
     }
 
-    private static List<CartridgeBean> getAvailableLbCartridges(Boolean multiTenant,
-                                                                ConfigurationContext configurationContext) throws RestAPIException {
+    private static List<CartridgeBean> getAvailableLbCartridges(
+            Boolean multiTenant, ConfigurationContext configurationContext) throws RestAPIException {
         List<CartridgeBean> cartridges = getAvailableCartridges(null, multiTenant,
                 configurationContext);
         List<CartridgeBean> lbCartridges = new ArrayList<CartridgeBean>();
@@ -228,12 +225,12 @@ public class StratosApiV41Utils {
 
     /**
      * Get the available cartridges by provider
+     *
      * @param provider provide name
-     * @param configurationContext configuration context
      * @return List of the cartridge definitions
      * @throws RestAPIException
      */
-    private static List<CartridgeBean> getAvailableCartridgesByProvider(String provider, ConfigurationContext configurationContext) throws RestAPIException {
+    private static List<CartridgeBean> getAvailableCartridgesByProvider(String provider) throws RestAPIException {
         List<CartridgeBean> cartridges = new ArrayList<CartridgeBean>();
 
         if (log.isDebugEnabled()) {
@@ -296,14 +293,17 @@ public class StratosApiV41Utils {
         return cartridges;
     }
 
-    public static List<CartridgeBean> getAvailableCartridges(String cartridgeSearchString, Boolean multiTenant, ConfigurationContext configurationContext) throws RestAPIException {
+    public static List<CartridgeBean> getAvailableCartridges(
+            String cartridgeSearchString, Boolean multiTenant, ConfigurationContext configurationContext)
+            throws RestAPIException {
+
         List<CartridgeBean> cartridges = new ArrayList<CartridgeBean>();
 
         if (log.isDebugEnabled()) {
-            log.debug("Getting available cartridges. Search String: " + cartridgeSearchString + ", Multi-Tenant: " + multiTenant);
+            log.debug("Getting available cartridges. [Search String]: " + cartridgeSearchString + ", [Multi-Tenant]: " + multiTenant);
         }
 
-        boolean allowMultipleSubscription = new Boolean(
+        boolean allowMultipleSubscription = Boolean.valueOf(
                 System.getProperty(CartridgeConstants.FEATURE_MULTI_TENANT_MULTIPLE_SUBSCRIPTION_ENABLED));
 
         try {
@@ -470,8 +470,7 @@ public class StratosApiV41Utils {
                 log.debug("Created regex: " + regex + " for search string " + searchString);
             }
 
-            Pattern pattern = Pattern.compile(regex);
-            return pattern;
+            return Pattern.compile(regex);
         }
         return null;
     }
@@ -564,7 +563,8 @@ public class StratosApiV41Utils {
 
         AutoscalerServiceClient serviceClient = getAutoscalerServiceClient();
         try {
-            ApplicationPolicy applicationPolicy = ObjectConverter.convertApplicationPolicyBeanToStubAppPolicy(applicationPolicyBean);
+            ApplicationPolicy applicationPolicy = ObjectConverter.convertApplicationPolicyBeanToStubAppPolicy(
+                    applicationPolicyBean);
             if (applicationPolicy == null) {
                 String msg = "Application policy is null";
                 log.error(msg);
@@ -597,7 +597,8 @@ public class StratosApiV41Utils {
         AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
         if (autoscalerServiceClient != null) {
 
-            ApplicationPolicy applicationPolicy = ObjectConverter.convertApplicationPolicyBeanToStubAppPolicy(applicationPolicyBean);
+            ApplicationPolicy applicationPolicy = ObjectConverter.convertApplicationPolicyBeanToStubAppPolicy(
+                    applicationPolicyBean);
 
             try {
                 autoscalerServiceClient.updateApplicationPolicy(applicationPolicy);
@@ -606,7 +607,8 @@ public class StratosApiV41Utils {
                 log.error(msg, e);
                 throw new RestAPIException(msg);
             } catch (AutoscalerServiceApplicatioinPolicyNotExistsExceptionException e) {
-                String msg = "Could not update application policy. Application policy not exists" + e.getLocalizedMessage();
+                String msg = "Could not update application policy. Application policy not exists" +
+                        e.getLocalizedMessage();
                 log.error(msg, e);
                 throw new RestAPIException(msg);
             } catch (AutoscalerServiceRemoteExceptionException e) {
@@ -656,7 +658,8 @@ public class StratosApiV41Utils {
             ApplicationPolicy applicationPolicy = serviceClient.getApplicationPolicy(applicationPolicyId);
             return ObjectConverter.convertASStubApplicationPolicyToApplicationPolicy(applicationPolicy);
         } catch (Exception e) {
-            String message = String.format("Could not get application policy [application-policy-id] %s", applicationPolicyId);
+            String message = String.format("Could not get application policy [application-policy-id] %s",
+                    applicationPolicyId);
             log.error(message);
             throw new RuntimeException(message, e);
         }
@@ -792,8 +795,8 @@ public class StratosApiV41Utils {
 
             List<String> cartridgeTypes = new ArrayList<String>();
             String[] cartridgeNames = null;
-            List<String> groupNames = null;
-            String[] cartridgeGroupNames = null;
+            List<String> groupNames;
+            String[] cartridgeGroupNames;
 
             // if any cartridges are specified in the group, they should be already deployed
             if (serviceGroupDefinition.getCartridges() != null) {
@@ -806,14 +809,15 @@ public class StratosApiV41Utils {
 
                 Set<String> duplicates = findDuplicates(cartridgeTypes);
                 if (duplicates.size() > 0) {
-                    StringBuffer buf = new StringBuffer();
+                    StringBuilder duplicatesOutput = new StringBuilder();
                     for (String dup : duplicates) {
-                        buf.append(dup).append(" ");
+                        duplicatesOutput.append(dup).append(" ");
                     }
                     if (log.isDebugEnabled()) {
-                        log.debug("duplicate cartridges defined: " + buf.toString());
+                        log.debug("duplicate cartridges defined: " + duplicatesOutput.toString());
                     }
-                    throw new RestAPIException("Invalid Service Group definition, duplicate cartridges defined:" + buf.toString());
+                    throw new RestAPIException("Invalid Service Group definition, duplicate cartridges defined:" +
+                            duplicatesOutput.toString());
                 }
 
                 CloudControllerServiceClient ccServiceClient = getCloudControllerServiceClient();
@@ -857,28 +861,27 @@ public class StratosApiV41Utils {
                 Set<String> duplicates = findDuplicates(groupNames);
                 if (duplicates.size() > 0) {
 
-                    StringBuffer buf = new StringBuffer();
+                    StringBuilder duplicatesOutput = new StringBuilder();
                     for (String dup : duplicates) {
-                        buf.append(dup).append(" ");
+                        duplicatesOutput.append(dup).append(" ");
                     }
                     if (log.isDebugEnabled()) {
-                        log.debug("duplicate subGroups defined: " + buf.toString());
+                        log.debug("duplicate subGroups defined: " + duplicatesOutput.toString());
                     }
-                    throw new RestAPIException("Invalid Service Group definition, duplicate subGroups defined:" + buf.toString());
+                    throw new RestAPIException("Invalid Service Group definition, duplicate subGroups defined:" +
+                            duplicatesOutput.toString());
                 }
             }
 
-            ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition);
+            ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(
+                    serviceGroupDefinition);
 
             AutoscalerServiceClient asServiceClient = getAutoscalerServiceClient();
             asServiceClient.addServiceGroup(serviceGroup);
 
             // Add cartridge group elements to SM cache - done after service group has been added
             StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
-            if (cartridgeTypes != null) {
-                smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroupDefinition.getName(), cartridgeNames);
-            }
-
+            smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroupDefinition.getName(), cartridgeNames);
         } catch (Exception e) {
             String message = "Could not add cartridge group";
             log.error(message, e);
@@ -889,8 +892,8 @@ public class StratosApiV41Utils {
     /**
      * returns any duplicates in a List
      *
-     * @param checkedList
-     * @return
+     * @param checkedList List to find duplicates from
+     * @return Set of duplicates
      */
     private static Set<String> findDuplicates(List<String> checkedList) {
         final Set<String> retVals = new HashSet<String>();
@@ -918,8 +921,7 @@ public class StratosApiV41Utils {
                 return null;
             }
 
-            GroupBean serviceGroupDef = ObjectConverter.convertStubServiceGroupToServiceGroupDefinition(serviceGroup);
-            return serviceGroupDef;
+            return ObjectConverter.convertStubServiceGroupToServiceGroupDefinition(serviceGroup);
 
         } catch (Exception e) {
             String message = "Could not get cartridge group: [group-name] " + name;
@@ -943,7 +945,8 @@ public class StratosApiV41Utils {
 
             GroupBean[] serviceGroupDefinitions = new GroupBean[serviceGroups.length];
             for (int i = 0; i < serviceGroups.length; i++) {
-                serviceGroupDefinitions[i] = ObjectConverter.convertStubServiceGroupToServiceGroupDefinition(serviceGroups[i]);
+                serviceGroupDefinitions[i] = ObjectConverter.convertStubServiceGroupToServiceGroupDefinition(
+                        serviceGroups[i]);
             }
             return serviceGroupDefinitions;
 
@@ -1039,10 +1042,11 @@ public class StratosApiV41Utils {
 
     /**
      * Verify the existence of the application and add it.
-     * @param appDefinition
-     * @param ctxt
-     * @param userName
-     * @param tenantDomain
+     *
+     * @param appDefinition Application definition
+     * @param ctxt Configuration context
+     * @param userName Username
+     * @param tenantDomain Tenant Domain
      * @throws RestAPIException
      */
     public static void addApplication(ApplicationBean appDefinition, ConfigurationContext ctxt,
@@ -1066,7 +1070,8 @@ public class StratosApiV41Utils {
 
         validateApplication(appDefinition);
 
-        ApplicationContext applicationContext = ObjectConverter.convertApplicationDefinitionToStubApplicationContext(appDefinition);
+        ApplicationContext applicationContext = ObjectConverter.convertApplicationDefinitionToStubApplicationContext(
+                appDefinition);
         applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
         applicationContext.setTenantDomain(tenantDomain);
         applicationContext.setTenantAdminUsername(userName);
@@ -1089,8 +1094,13 @@ public class StratosApiV41Utils {
             List<String> usedCartridgeGroups = new ArrayList<String>();
             findCartridgesAndGroupsInApplication(appDefinition, usedCartridges, usedCartridgeGroups);
             StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
-            smServiceClient.addUsedCartridgesInApplications(appDefinition.getApplicationId(), usedCartridges.toArray(new String[usedCartridges.size()]));
-            smServiceClient.addUsedCartridgeGroupsInApplications(appDefinition.getApplicationId(), usedCartridgeGroups.toArray(new String[usedCartridgeGroups.size()]));
+            smServiceClient.addUsedCartridgesInApplications(
+                    appDefinition.getApplicationId(),
+                    usedCartridges.toArray(new String[usedCartridges.size()]));
+
+            smServiceClient.addUsedCartridgeGroupsInApplications(
+                    appDefinition.getApplicationId(),
+                    usedCartridgeGroups.toArray(new String[usedCartridgeGroups.size()]));
 
         } catch (AutoscalerServiceApplicationDefinitionExceptionException e) {
             throw new RestAPIException(e);
@@ -1099,7 +1109,8 @@ public class StratosApiV41Utils {
         }
     }
 
-    private static void findCartridgesAndGroupsInApplication(ApplicationBean applicationBean, List<String> cartridges, List<String> cartridgeGroups) {
+    private static void findCartridgesAndGroupsInApplication(
+            ApplicationBean applicationBean, List<String> cartridges, List<String> cartridgeGroups) {
 
         if (applicationBean == null || applicationBean.getComponents() == null) {
             return;
@@ -1118,7 +1129,8 @@ public class StratosApiV41Utils {
         findCartridgeNamesInCartridges(cartridgeReferenceBeans, cartridges);
     }
 
-    private static void findCartridgesAndGroupsInCartridgeGroup(GroupReferenceBean groupReferenceBean, List<String> cartridges, List<String> cartridgeGroups) {
+    private static void findCartridgesAndGroupsInCartridgeGroup(
+            GroupReferenceBean groupReferenceBean, List<String> cartridges, List<String> cartridgeGroups) {
 
         if (groupReferenceBean == null || cartridgeGroups == null) {
             return;
@@ -1138,7 +1150,8 @@ public class StratosApiV41Utils {
         findCartridgeNamesInCartridges(groupReferenceBean.getCartridges(), cartridges);
     }
 
-    private static void findCartridgeNamesInCartridges(List<CartridgeReferenceBean> cartridgeReferenceBeans, List<String> cartridges) {
+    private static void findCartridgeNamesInCartridges(
+            List<CartridgeReferenceBean> cartridgeReferenceBeans, List<String> cartridges) {
 
         if (cartridgeReferenceBeans == null || cartridges == null) {
             return;
@@ -1163,8 +1176,8 @@ public class StratosApiV41Utils {
     /**
      * Deploy application with an application policy.
      *
-     * @param applicationId
-     * @param applicationPolicyId
+     * @param applicationId Application ID
+     * @param applicationPolicyId Application policy Id
      * @throws RestAPIException
      */
     public static void deployApplication(String applicationId, String applicationPolicyId)
@@ -1203,14 +1216,21 @@ public class StratosApiV41Utils {
             }
 
             if (application.getStatus().equalsIgnoreCase(APPLICATION_STATUS_DEPLOYED)) {
-                String message = String.format("Application is already in DEPLOYED state: [application-id] %s [current status] %s ", applicationId, application.getStatus());
+                String message = String.format(
+                        "Application is already in DEPLOYED state: [application-id] %s [current status] %s ",
+                        applicationId,
+                        application.getStatus());
                 log.error(message);
                 throw new RestAPIException(message);
             }
 
-            // This is a redundant state since there is only CREATED,DEPLOYED state. But this will be usefull when more status are added.
+            // This is a redundant state since there is only CREATED,DEPLOYED state.
+            // But this will be usefull when more status are added.
             if (!application.getStatus().equalsIgnoreCase(APPLICATION_STATUS_CREATED)) {
-                String message = String.format("Application is not in CREATED state: [application-id] %s [current status] %s ", applicationId, application.getStatus());
+                String message = String.format(
+                        "Application is not in CREATED state: [application-id] %s [current status] %s ",
+                        applicationId,
+                        application.getStatus());
                 log.error(message);
                 throw new RestAPIException(message);
             }
@@ -1218,7 +1238,9 @@ public class StratosApiV41Utils {
             ApplicationBean applicationBean = getApplication(applicationId);
             int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
             if (applicationBean.isMultiTenant() && (tenantId != -1234)) {
-                String message = String.format("Multi-tenant applications can only be deployed by super tenant: [application-id] %s", applicationId);
+                String message = String.format(
+                        "Multi-tenant applications can only be deployed by super tenant: [application-id] %s",
+                        applicationId);
                 log.error(message);
                 throw new RestAPIException(message);
             }
@@ -1257,7 +1279,8 @@ public class StratosApiV41Utils {
 
     /**
      * Validate deployment policy
-     * @param deploymentPolicy
+     *
+     * @param deploymentPolicy Deployment Policy
      */
     private static void validateDeploymentPolicy(DeploymentPolicyBean deploymentPolicy) throws RestAPIException {
         if (StringUtils.isBlank(deploymentPolicy.getId())) {
@@ -1281,15 +1304,22 @@ public class StratosApiV41Utils {
 
             AutoscalerServiceClient asServiceClient = getAutoscalerServiceClient();
 
-            ApplicationBean application = ObjectConverter.convertStubApplicationContextToApplicationDefinition(asServiceClient.getApplication(applicationId));
+            ApplicationContext asApplication = asServiceClient.getApplication(applicationId);
+            ApplicationBean application = ObjectConverter.convertStubApplicationContextToApplicationDefinition(
+                    asApplication);
             asServiceClient.deleteApplication(applicationId);
 
             List<String> usedCartridges = new ArrayList<String>();
             List<String> usedCartridgeGroups = new ArrayList<String>();
             findCartridgesAndGroupsInApplication(application, usedCartridges, usedCartridgeGroups);
             StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
-            smServiceClient.removeUsedCartridgesInApplications(application.getApplicationId(), usedCartridges.toArray(new String[usedCartridges.size()]));
-            smServiceClient.removeUsedCartridgeGroupsInApplications(application.getApplicationId(), usedCartridgeGroups.toArray(new String[usedCartridgeGroups.size()]));
+            smServiceClient.removeUsedCartridgesInApplications(
+                    application.getApplicationId(),
+                    usedCartridges.toArray(new String[usedCartridges.size()]));
+
+            smServiceClient.removeUsedCartridgeGroupsInApplications(
+                    application.getApplicationId(),
+                    usedCartridgeGroups.toArray(new String[usedCartridgeGroups.size()]));
 
         } catch (RemoteException e) {
             String message = "Could not delete application: [application-id] " + applicationId;
@@ -1411,7 +1441,8 @@ public class StratosApiV41Utils {
 
     }
 
-    private static void addClustersInstancesToApplicationInstanceBean(ApplicationInstanceBean applicationInstanceBean, Application application) {
+    private static void addClustersInstancesToApplicationInstanceBean(
+            ApplicationInstanceBean applicationInstanceBean, Application application) {
 
         Map<String, ClusterDataHolder> topLevelClusterDataMap = application.getClusterDataMap();
         if (topLevelClusterDataMap != null) {
@@ -1632,7 +1663,8 @@ public class StratosApiV41Utils {
                 org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesHost[]
                         kubernetesHosts = cloudControllerServiceClient.getKubernetesHosts(kubernetesClusterId);
 
-                List<KubernetesHostBean> arrayList = ObjectConverter.convertStubKubernetesHostsToKubernetesHosts(kubernetesHosts);
+                List<KubernetesHostBean> arrayList = ObjectConverter.convertStubKubernetesHostsToKubernetesHosts(
+                        kubernetesHosts);
                 KubernetesHostBean[] array = new KubernetesHostBean[arrayList.size()];
                 array = arrayList.toArray(array);
                 return array;
@@ -1691,7 +1723,9 @@ public class StratosApiV41Utils {
         return false;
     }
 
-    public static void addApplicationSignUp(String applicationId, ApplicationSignUpBean applicationSignUpBean) throws RestAPIException {
+    public static void addApplicationSignUp(String applicationId, ApplicationSignUpBean applicationSignUpBean)
+            throws RestAPIException {
+
         if (StringUtils.isBlank(applicationId)) {
             throw new RestAPIException("Application id is null");
         }
@@ -1722,7 +1756,8 @@ public class StratosApiV41Utils {
 
             int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
 
-            ApplicationSignUp applicationSignUp = ObjectConverter.convertApplicationSignUpBeanToStubApplicationSignUp(applicationSignUpBean);
+            ApplicationSignUp applicationSignUp = ObjectConverter.convertApplicationSignUpBeanToStubApplicationSignUp(
+                    applicationSignUpBean);
             applicationSignUp.setApplicationId(applicationId);
             applicationSignUp.setTenantId(tenantId);
             List<String> clusterIds = findApplicationClusterIds(application);
@@ -1754,8 +1789,9 @@ public class StratosApiV41Utils {
 
     /**
      * Find application cluster ids.
-     * @param application
-     * @return
+     *
+     * @param application Application
+     * @return list of cluster Ids
      */
     private static List<String> findApplicationClusterIds(Application application) {
         List<String> clusterIds = new ArrayList<String>();
@@ -1767,22 +1803,25 @@ public class StratosApiV41Utils {
 
     /**
      * Encrypt artifact repository passwords.
-     * @param applicationSignUp
-     * @param applicationKey
+     *
+     * @param applicationSignUp Application Signup
+     * @param applicationKey Application Key
      */
     private static void encryptRepositoryPasswords(ApplicationSignUp applicationSignUp, String applicationKey) {
         if (applicationSignUp.getArtifactRepositories() != null) {
             for (ArtifactRepository artifactRepository : applicationSignUp.getArtifactRepositories()) {
-                String repoPassword = artifactRepository.getRepoPassword();
-                if ((artifactRepository != null) && (StringUtils.isNotBlank(repoPassword))) {
-                    String encryptedRepoPassword = CommonUtil.encryptPassword(repoPassword,
-                            applicationKey);
-                    artifactRepository.setRepoPassword(encryptedRepoPassword);
+                if (artifactRepository != null) {
+                    String repoPassword = artifactRepository.getRepoPassword();
+                    if ((StringUtils.isNotBlank(repoPassword))) {
+                        String encryptedRepoPassword = CommonUtil.encryptPassword(repoPassword,
+                                applicationKey);
+                        artifactRepository.setRepoPassword(encryptedRepoPassword);
 
-                    if (log.isDebugEnabled()) {
-                        log.debug(String.format("Artifact repository password encrypted: [application-id] %s " +
-                                        "[tenant-id] %d [repo-url] %s", applicationSignUp.getApplicationId(),
-                                applicationSignUp.getTenantId(), artifactRepository.getRepoUrl()));
+                        if (log.isDebugEnabled()) {
+                            log.debug(String.format("Artifact repository password encrypted: [application-id] %s " +
+                                            "[tenant-id] %d [repo-url] %s", applicationSignUp.getApplicationId(),
+                                    applicationSignUp.getTenantId(), artifactRepository.getRepoUrl()));
+                        }
                     }
                 }
             }
@@ -1887,8 +1926,8 @@ public class StratosApiV41Utils {
         }
     }
 
-    public static void addApplicationDomainMappings(String applicationId,
-                                                    ApplicationDomainMappingsBean domainMapppingsBean) throws RestAPIException {
+    public static void addApplicationDomainMappings(
+            String applicationId, ApplicationDomainMappingsBean domainMapppingsBean) throws RestAPIException {
 
         try {
             int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
@@ -1896,9 +1935,12 @@ public class StratosApiV41Utils {
                 StratosManagerServiceClient serviceClient = StratosManagerServiceClient.getInstance();
 
                 for (DomainMappingBean domainMappingBean : domainMapppingsBean.getDomainMappings()) {
-                    ClusterDataHolder clusterDataHolder = findClusterDataHolder(applicationId, domainMappingBean.getCartridgeAlias());
+                    ClusterDataHolder clusterDataHolder = findClusterDataHolder(
+                            applicationId,
+                            domainMappingBean.getCartridgeAlias());
 
-                    DomainMapping domainMapping = ObjectConverter.convertDomainMappingBeanToStubDomainMapping(domainMappingBean);
+                    DomainMapping domainMapping = ObjectConverter.convertDomainMappingBeanToStubDomainMapping(
+                            domainMappingBean);
                     domainMapping.setApplicationId(applicationId);
                     domainMapping.setTenantId(tenantId);
                     domainMapping.setServiceName(clusterDataHolder.getServiceType());
@@ -1968,7 +2010,8 @@ public class StratosApiV41Utils {
             if (domainMappings != null) {
                 for (DomainMapping domainMapping : domainMappings) {
                     if (domainMapping != null) {
-                        DomainMappingBean domainMappingBean = ObjectConverter.convertStubDomainMappingToDomainMappingBean(domainMapping);
+                        DomainMappingBean domainMappingBean =
+                                ObjectConverter.convertStubDomainMappingToDomainMappingBean(domainMapping);
                         domainMappingsBeans.add(domainMappingBean);
                     }
                 }
@@ -1984,7 +2027,8 @@ public class StratosApiV41Utils {
     public static void addNetworkPartition(NetworkPartitionBean networkPartitionBean) {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
-            serviceClient.addNetworkPartition(ObjectConverter.convertNetworkPartitionToCCStubNetworkPartition(networkPartitionBean));
+            serviceClient.addNetworkPartition(
+                    ObjectConverter.convertNetworkPartitionToCCStubNetworkPartition(networkPartitionBean));
         } catch (Exception e) {
             String message = "Could not add network partition";
             log.error(message);
@@ -1995,7 +2039,8 @@ public class StratosApiV41Utils {
     public static NetworkPartitionBean[] getNetworkPartitions() {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
-            org.apache.stratos.cloud.controller.stub.domain.NetworkPartition[] networkPartitions = serviceClient.getNetworkPartitions();
+            org.apache.stratos.cloud.controller.stub.domain.NetworkPartition[] networkPartitions =
+                    serviceClient.getNetworkPartitions();
             return ObjectConverter.convertCCStubNetworkPartitionsToNetworkPartitions(networkPartitions);
         } catch (Exception e) {
             String message = "Could not get network partitions";
@@ -2009,7 +2054,9 @@ public class StratosApiV41Utils {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
             serviceClient.removeNetworkPartition(networkPartitionId);
         } catch (Exception e) {
-            String message = String.format("Could not remove network partition: [network-partition-id] %s", networkPartitionId);
+            String message = String.format(
+                    "Could not remove network partition: [network-partition-id] %s",
+                    networkPartitionId);
             log.error(message);
             throw new RuntimeException(message, e);
         }
@@ -2018,10 +2065,13 @@ public class StratosApiV41Utils {
     public static NetworkPartitionBean getNetworkPartition(String networkPartitionId) {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
-            org.apache.stratos.cloud.controller.stub.domain.NetworkPartition networkPartition = serviceClient.getNetworkPartition(networkPartitionId);
+            org.apache.stratos.cloud.controller.stub.domain.NetworkPartition networkPartition =
+                    serviceClient.getNetworkPartition(networkPartitionId);
             return ObjectConverter.convertCCStubNetworkPartitionToNetworkPartition(networkPartition);
         } catch (Exception e) {
-            String message = String.format("Could not get network partition: [network-partition-id] %s", networkPartitionId);
+            String message = String.format(
+                    "Could not get network partition: [network-partition-id] %s",
+                    networkPartitionId);
             log.error(message);
             throw new RuntimeException(message, e);
         }
@@ -2076,12 +2126,13 @@ public class StratosApiV41Utils {
 
     /**
      * Get deployment policy by deployment policy id
+     *
      * @param deploymentPolicyID deployment policy id
      * @return {@link DeploymentPolicyBean}
      */
     public static DeploymentPolicyBean getDeployementPolicy(String deploymentPolicyID) throws RestAPIException {
 
-        DeploymentPolicyBean deploymentPolicyBean = null;
+        DeploymentPolicyBean deploymentPolicyBean;
         try {
 
             org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy deploymentPolicy
@@ -2095,6 +2146,7 @@ public class StratosApiV41Utils {
             log.error(msg, e);
             throw new RestAPIException(msg);
         }
+        
         return deploymentPolicyBean;
     }
 
@@ -2117,6 +2169,7 @@ public class StratosApiV41Utils {
 
     /**
      * Update deployement policy
+     *
      * @param deploymentPolicyDefinitionBean DeploymentPolicyBean
      * @throws RestAPIException
      */
@@ -2151,6 +2204,7 @@ public class StratosApiV41Utils {
 
     /**
      * Remove deployment policy
+     *
      * @param deploymentPolicyID Deployment policy ID
      * @throws RestAPIException
      */


[2/3] stratos git commit: REST API - Improved comments for the API methods Fixed wong status codes being returned from operations Fixed multiple status codes being returned from operations Fixed minor status message typos Fixed status codes not being ret

Posted by ch...@apache.org.
REST API - Improved comments for the API methods
Fixed wong status codes being returned from operations
Fixed multiple status codes being returned from operations
Fixed minor status message typos
Fixed status codes not being returned from some operations


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

Branch: refs/heads/master
Commit: d42e63efb600e4cdfcd6d9f3d7491534ed083242
Parents: cbc1b37
Author: Chamila de Alwis <ch...@apache.org>
Authored: Tue Apr 14 03:32:55 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Tue Apr 14 03:32:55 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41.java        | 238 +++++++++++--------
 .../rest/endpoint/api/StratosApiV41Utils.java   |  20 +-
 2 files changed, 154 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d42e63ef/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 1ac626e..3b1287d 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
@@ -20,10 +20,7 @@ package org.apache.stratos.rest.endpoint.api;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.ApiResponseBean;
-import org.apache.stratos.common.beans.ErrorResponseBean;
-import org.apache.stratos.common.beans.SuccessResponseBean;
-import org.apache.stratos.common.beans.UserInfoBean;
+import org.apache.stratos.common.beans.*;
 import org.apache.stratos.common.beans.application.ApplicationBean;
 import org.apache.stratos.common.beans.application.ApplicationNetworkPartitionIdListBean;
 import org.apache.stratos.common.beans.application.GroupBean;
@@ -111,7 +108,7 @@ public class StratosApiV41 extends AbstractApi {
      * themselves in subsequent calls. This method call get authenticated by the basic authenticator.
      * Once the authenticated call received, the method creates a session and returns the session id.
      *
-     * @return
+     * @return The session id related with the session
      */
     @GET
     @Path("/session")
@@ -130,13 +127,11 @@ public class StratosApiV41 extends AbstractApi {
                 entity(Utils.buildAuthenticationSuccessMessage(sessionId)).build();
     }
 
-    // API methods for cartridges
-
     /**
      * Creates the cartridge definition.
      *
      * @param cartridgeDefinitionBean the cartridge definition bean
-     * @return the response
+     * @return 201 if cartridge is successfully created, 409 if cartridge already exists.
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -163,10 +158,10 @@ public class StratosApiV41 extends AbstractApi {
     }
 
     /**
-     * Creates the Deployement Policy Definition.
+     * Creates the Deployment Policy Definition.
      *
      * @param deploymentPolicyDefinitionBean the deployment policy bean
-     * @return the response
+     * @return 201 if deployment policy is successfully added
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -189,7 +184,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Get deployment policy by deployment policy id
      *
-     * @return the response
+     * @return 200 if deployment policy is found, 404 if not
      * @throws RestAPIException
      */
     @GET
@@ -209,7 +204,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Get deployment policies
      *
-     * @return the response
+     * @return 200 with the list of deployment policies
      * @throws RestAPIException
      */
     @GET
@@ -227,7 +222,7 @@ public class StratosApiV41 extends AbstractApi {
      * Updates the Deployment Policy Definition.
      *
      * @param deploymentPolicyDefinitionBean the deployment policy bean
-     * @return the response
+     * @return 200 if deployment policy is successfully updated
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -243,7 +238,7 @@ public class StratosApiV41 extends AbstractApi {
 
         StratosApiV41Utils.updateDeploymentPolicy(deploymentPolicyDefinitionBean);
         URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
-        return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+        return Response.ok(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Deployment policy updated successfully: " + "[deployment-policy-id] %s",
                         deploymentPolicyID))).build();
     }
@@ -252,7 +247,7 @@ public class StratosApiV41 extends AbstractApi {
      * Updates the Deployment Policy Definition.
      *
      * @param deploymentPolicyID the deployment policy id
-     * @return the response
+     * @return 200 if deployment policy is successfully removed
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -265,7 +260,7 @@ public class StratosApiV41 extends AbstractApi {
 
         StratosApiV41Utils.removeDeploymentPolicy(deploymentPolicyID);
         URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
-        return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+        return Response.ok(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Deployment policy removed successfully: " + "[deployment-policy-id] %s",
                         deploymentPolicyID))).build();
     }
@@ -274,7 +269,7 @@ public class StratosApiV41 extends AbstractApi {
      * Updates the cartridge definition.
      *
      * @param cartridgeDefinitionBean the cartridge definition bean
-     * @return the response
+     * @return 201 if cartridge successfully updated
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -295,7 +290,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Gets all available cartridges.
      *
-     * @return the cartridges
+     * @return 200 if cartridges exists, 404 if no cartridges found
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -315,6 +310,12 @@ public class StratosApiV41 extends AbstractApi {
         return Response.ok().entity(cartridgeArray).build();
     }
 
+    /**
+     * Gets a single cartridge by type
+     * @param cartridgeType
+     * @return 200 if specified cartridge exists, 404 if not
+     * @throws RestAPIException
+     */
     @GET
     @Path("/cartridges/{cartridgeType}")
     @Produces("application/json")
@@ -334,7 +335,7 @@ public class StratosApiV41 extends AbstractApi {
      *
      * @param filter
      * @param criteria
-     * @return
+     * @return 200 if cartridges are found for specified filter, 404 if none found
      * @throws RestAPIException
      */
     @GET
@@ -361,7 +362,7 @@ public class StratosApiV41 extends AbstractApi {
      *
      * @param filter
      * @param cartridgeType
-     * @return
+     * @return 200 if a cartridge is found for specified filter, 404 if none found
      * @throws RestAPIException
      */
     @GET
@@ -383,7 +384,7 @@ public class StratosApiV41 extends AbstractApi {
      * Deletes a cartridge definition.
      *
      * @param cartridgeType the cartridge type
-     * @return the response
+     * @return 200 if cartridge is successfully removed
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -405,7 +406,7 @@ public class StratosApiV41 extends AbstractApi {
      * Creates the cartridge group definition.
      *
      * @param serviceGroupDefinition the cartridge group definition
-     * @return the response
+     * @return 201 if group added successfully
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -427,7 +428,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the cartridge group definition.
      *
      * @param groupDefinitionName the group definition name
-     * @return the cartridge group definition
+     * @return 200 if cartridge group found for group definition, 404 if none is found
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -451,7 +452,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Gets all cartridge groups created.
      *
-     * @return the cartridge groups
+     * @return 200 if cartridge groups are found, 404 if none found
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -476,7 +477,7 @@ public class StratosApiV41 extends AbstractApi {
      * Delete cartridge group definition.
      *
      * @param groupDefinitionName the group definition name
-     * @return the response
+     * @return 200 if cartridge group is successfully removed
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -500,7 +501,7 @@ public class StratosApiV41 extends AbstractApi {
      * Add network partition
      *
      * @param networkPartitionBean
-     * @return
+     * @return 201 if network partition successfully added, 409 if network partition already exists
      * @throws RestAPIException
      */
     @POST
@@ -529,7 +530,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Get network partitions
      *
-     * @return
+     * @return 200 if network partitions are found
      * @throws RestAPIException
      */
     @GET
@@ -546,7 +547,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Get network partition by network partition id
      *
-     * @return
+     * @return 200 if specified network partition is found
      * @throws RestAPIException
      */
     @GET
@@ -563,7 +564,8 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Remove network partition by network partition id
      *
-     * @return
+     * @return 200 if specified network partition is successfully deleted, 404 if specified network partition is not
+     * found
      * @throws RestAPIException
      */
     @DELETE
@@ -587,7 +589,7 @@ public class StratosApiV41 extends AbstractApi {
      * Add application
      *
      * @param applicationDefinition
-     * @return
+     * @return 201 if application is successfully added
      * @throws RestAPIException
      */
     @POST
@@ -607,7 +609,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Return applications
      *
-     * @return
+     * @return 200 if applications are found
      * @throws RestAPIException
      */
     @GET
@@ -626,7 +628,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the application.
      *
      * @param applicationId the application id
-     * @return the application
+     * @return 200 if specified application is found, 404 if not
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -648,7 +650,7 @@ public class StratosApiV41 extends AbstractApi {
      *
      * @param applicationId
      * @param applicationPolicyId the application policy id
-     * @return the response
+     * @return 202 after deployment process is started. Deployment is asynchronous
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -664,6 +666,12 @@ public class StratosApiV41 extends AbstractApi {
                 String.format("Application deployed successfully: [application] %s", applicationId))).build();
     }
 
+    /**
+     * Adds an application policy
+     * @param applicationPolicy
+     * @return 201 if the application policy is successfully added
+     * @throws RestAPIException
+     */
     @POST
     @Path("/applicationPolicies")
     @Produces("application/json")
@@ -678,6 +686,13 @@ public class StratosApiV41 extends AbstractApi {
                         applicationPolicy.getId()))).build();
     }
 
+    /**
+     * Retrieve specified application policy
+     *
+     * @param applicationPolicyId
+     * @return 200 if application policy is found
+     * @throws RestAPIException
+     */
     @GET
     @Path("/applicationPolicies/{applicationPolicyId}")
     @Produces("application/json")
@@ -689,6 +704,12 @@ public class StratosApiV41 extends AbstractApi {
         return Response.ok(applicationPolicyBean).build();
     }
 
+    /**
+     * Retrieve all application policies
+     *
+     * @return 200
+     * @throws RestAPIException
+     */
     @GET
     @Path("/applicationPolicies")
     @Produces("application/json")
@@ -699,6 +720,13 @@ public class StratosApiV41 extends AbstractApi {
         return Response.ok().entity(StratosApiV41Utils.getApplicationPolicies()).build();
     }
 
+    /**
+     * Remove specified application policy
+     *
+     * @param applicationPolicyId
+     * @return 200 if application policy is successfully removed
+     * @throws RestAPIException
+     */
     @DELETE
     @Path("/applicationPolicies/{applicationPolicyId}")
     @Produces("application/json")
@@ -709,10 +737,17 @@ public class StratosApiV41 extends AbstractApi {
 
         StratosApiV41Utils.removeApplicationPolicy(applicationPolicyId);
         return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
-                String.format("Autoscaling policy deleted successfully: [autoscale-policy] %s",
+                String.format("Application policy deleted successfully: [application-policy] %s",
                         applicationPolicyId))).build();
     }
 
+    /**
+     * Update application policy
+     *
+     * @param applicationPolicy
+     * @return 200 if application policies successfully updated
+     * @throws RestAPIException
+     */
     @PUT
     @Path("/applicationPolicies")
     @Produces("application/json")
@@ -730,7 +765,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Get network partition ids used in an application
      *
-     * @return
+     * @return 200
      * @throws RestAPIException
      */
     @GET
@@ -750,7 +785,7 @@ public class StratosApiV41 extends AbstractApi {
      *
      * @param applicationId         the application id
      * @param applicationSignUpBean the application sign up bean
-     * @return the response
+     * @return 200 if application sign up was successfull
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -770,7 +805,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the application sign up.
      *
      * @param applicationId the application id
-     * @return the application sign up
+     * @return 200 if specified application signup is found, 404 if not
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -791,7 +826,7 @@ public class StratosApiV41 extends AbstractApi {
      * Removes the application sign up.
      *
      * @param applicationId the application id
-     * @return the response
+     * @return 200 if specified application sign up is removed
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -810,7 +845,7 @@ public class StratosApiV41 extends AbstractApi {
      *
      * @param applicationId       the application id
      * @param domainMapppingsBean the domain mapppings bean
-     * @return the response
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -837,7 +872,7 @@ public class StratosApiV41 extends AbstractApi {
      *
      * @param applicationId       the application id
      * @param domainMapppingsBean the domain mapppings bean
-     * @return the response
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -863,7 +898,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the domain mappings for an application.
      *
      * @param applicationId the application id
-     * @return the domain mappings
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -883,7 +918,8 @@ public class StratosApiV41 extends AbstractApi {
      * Undeploy an application.
      *
      * @param applicationId the application id
-     * @return the response
+     * @return 202 if undeployment process started, 404 if specified application is not found, 409 if application
+     * status is not in DEPLOYED state
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -896,7 +932,7 @@ public class StratosApiV41 extends AbstractApi {
 
         ApplicationBean applicationDefinition = StratosApiV41Utils.getApplication(applicationId);
         if (applicationDefinition == null) {
-            log.info(String.format("Application does not exist [application-id] ", applicationId));
+            log.info(String.format("Application does not exist [application-id] %s", applicationId));
             return Response.status(Response.Status.NOT_FOUND).build();
         }
         if (!applicationDefinition.getStatus().equalsIgnoreCase(StratosApiV41Utils.APPLICATION_STATUS_DEPLOYED)) {
@@ -936,7 +972,8 @@ public class StratosApiV41 extends AbstractApi {
      * Delete an application.
      *
      * @param applicationId the application id
-     * @return the response
+     * @return 200 if application is successfully removed, 404 if specified application is not found, 409 if
+     * application is not in CREATED state
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -967,7 +1004,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Gets the autoscaling policies.
      *
-     * @return the autoscaling policies
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -984,7 +1021,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the autoscaling policy.
      *
      * @param autoscalePolicyId the autoscale policy id
-     * @return the autoscaling policy
+     * @return 200 if specified autoscaling policy is found, 404 if not
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1005,7 +1042,7 @@ public class StratosApiV41 extends AbstractApi {
      * Creates the autoscaling policy defintion.
      *
      * @param autoscalePolicy the autoscale policy
-     * @return the response
+     * @return 201 if autoscale policy is successfully added
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -1027,7 +1064,7 @@ public class StratosApiV41 extends AbstractApi {
      * Update autoscaling policy.
      *
      * @param autoscalePolicy the autoscale policy
-     * @return the response
+     * @return 200 if autoscale policy is successfully updated
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -1044,6 +1081,12 @@ public class StratosApiV41 extends AbstractApi {
                         autoscalePolicy.getId()))).build();
     }
 
+    /**
+     * Updates a network partition
+     * @param networkPartition
+     * @return 200 if network partition is successfully updated
+     * @throws RestAPIException
+     */
     @PUT
     @Path("/networkPartitions")
     @Produces("application/json")
@@ -1062,7 +1105,7 @@ public class StratosApiV41 extends AbstractApi {
      * Remove autoscaling policy.
      *
      * @param autoscalingPolicyId the autoscale policy
-     * @return the response
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -1084,7 +1127,7 @@ public class StratosApiV41 extends AbstractApi {
      * Get cluster for a given cluster id
      *
      * @param clusterId id of the cluster
-     * @return the response
+     * @return 200 if specified cluster is found, 404 if not
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1110,7 +1153,7 @@ public class StratosApiV41 extends AbstractApi {
      * Adds the tenant.
      *
      * @param tenantInfoBean the tenant info bean
-     * @return the response
+     * @return 201 if the tenant is successfully added
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -1212,7 +1255,7 @@ public class StratosApiV41 extends AbstractApi {
      * Update tenant.
      *
      * @param tenantInfoBean the tenant info bean
-     * @return the response
+     * @return 200 if tenant is successfully updated, 404 if specified tenant not found
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -1359,7 +1402,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the tenant by domain.
      *
      * @param tenantDomain the tenant domain
-     * @return the tenant by domain
+     * @return 200 if tenant for specified tenant domain found
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1368,11 +1411,12 @@ public class StratosApiV41 extends AbstractApi {
     @Produces("application/json")
     @AuthorizationAction("/permission/protected/manage/getTenantForDomain")
     @SuperTenantService(true)
-    public org.apache.stratos.common.beans.TenantInfoBean getTenantForDomain(
+    public Response getTenantForDomain(
             @PathParam("tenantDomain") String tenantDomain) throws RestAPIException {
 
         try {
-            return getTenantByDomain(tenantDomain);
+            TenantInfoBean tenantInfo = getTenantByDomain(tenantDomain);
+            return Response.ok().entity(tenantInfo).build();
         } catch (Exception e) {
             String msg = "Error in getting tenant information for tenant " + tenantDomain;
             log.error(msg, e);
@@ -1426,7 +1470,7 @@ public class StratosApiV41 extends AbstractApi {
      * Delete tenant.
      *
      * @param tenantDomain the tenant domain
-     * @return the response
+     * @return 406 - Use tenantDeactivate method
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -1447,7 +1491,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Gets the tenants.
      *
-     * @return the tenants
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1455,17 +1499,17 @@ public class StratosApiV41 extends AbstractApi {
     @Produces("application/json")
     @AuthorizationAction("/permission/protected/manage/getTenants")
     @SuperTenantService(true)
-    public org.apache.stratos.common.beans.TenantInfoBean[] getTenants()
+    public Response getTenants()
             throws RestAPIException {
-        List<org.apache.stratos.common.beans.TenantInfoBean> tenantList = null;
         try {
-            tenantList = getAllTenants();
+            List<org.apache.stratos.common.beans.TenantInfoBean> tenantList = getAllTenants();
+            return Response.ok().entity(tenantList.toArray(
+                    new org.apache.stratos.common.beans.TenantInfoBean[tenantList.size()])).build();
         } catch (Exception e) {
             String msg = "Error in retrieving tenants";
             log.error(msg, e);
             throw new RestAPIException(msg);
         }
-        return tenantList.toArray(new org.apache.stratos.common.beans.TenantInfoBean[tenantList.size()]);
     }
 
     private List<org.apache.stratos.common.beans.TenantInfoBean> getAllTenants() throws RestAPIException {
@@ -1493,7 +1537,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the partial search tenants.
      *
      * @param tenantDomain the tenant domain
-     * @return the partial search tenants
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1502,18 +1546,17 @@ public class StratosApiV41 extends AbstractApi {
     @Produces("application/json")
     @AuthorizationAction("/permission/protected/manage/getTenants")
     @SuperTenantService(true)
-    public org.apache.stratos.common.beans.TenantInfoBean[] getPartialSearchTenants(
+    public Response getPartialSearchTenants(
             @PathParam("tenantDomain") String tenantDomain) throws RestAPIException {
 
-        List<org.apache.stratos.common.beans.TenantInfoBean> tenantList = null;
         try {
-            tenantList = searchPartialTenantsDomains(tenantDomain);
+            List<org.apache.stratos.common.beans.TenantInfoBean> tenantList = searchPartialTenantsDomains(tenantDomain);
+            return Response.ok().entity(tenantList.toArray(new org.apache.stratos.common.beans.TenantInfoBean[tenantList.size()])).build();
         } catch (Exception e) {
             String msg = "Error in getting information for tenant " + tenantDomain;
             log.error(msg, e);
             throw new RestAPIException(msg);
         }
-        return tenantList.toArray(new org.apache.stratos.common.beans.TenantInfoBean[tenantList.size()]);
     }
 
     private List<org.apache.stratos.common.beans.TenantInfoBean> searchPartialTenantsDomains(String domain)
@@ -1543,7 +1586,7 @@ public class StratosApiV41 extends AbstractApi {
      * Activate tenant.
      *
      * @param tenantDomain the tenant domain
-     * @return the response
+     * @return 200 if tenant activated successfully
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -1589,7 +1632,7 @@ public class StratosApiV41 extends AbstractApi {
      * Deactivate tenant.
      *
      * @param tenantDomain the tenant domain
-     * @return the response
+     * @return 200 if tenant deactivated successfully
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -1635,6 +1678,12 @@ public class StratosApiV41 extends AbstractApi {
 
     // API methods for repositories
 
+    /**
+     * Notify artifact update event for specified repository
+     * @param payload
+     * @return 204
+     * @throws RestAPIException
+     */
     @POST
     @Path("/repo/notify")
     @Produces("application/json")
@@ -1656,7 +1705,7 @@ public class StratosApiV41 extends AbstractApi {
      * Adds the user.
      *
      * @param userInfoBean the user info bean
-     * @return the response
+     * @return 201 if the user is successfully created
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -1677,7 +1726,7 @@ public class StratosApiV41 extends AbstractApi {
         }
         log.info("Successfully added an user with Username " + userInfoBean.getUserName());
         URI url = uriInfo.getAbsolutePathBuilder().path(userInfoBean.getUserName()).build();
-        return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+        return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
                 String.format("User added successfully: [user] %s", userInfoBean.getUserName()))).build();
     }
 
@@ -1685,7 +1734,7 @@ public class StratosApiV41 extends AbstractApi {
      * Delete user.
      *
      * @param userName the user name
-     * @return the response
+     * @return 200 if the user is successfully deleted
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -1712,7 +1761,7 @@ public class StratosApiV41 extends AbstractApi {
      * Update user.
      *
      * @param userInfoBean the user info bean
-     * @return the response
+     * @return 200 if the user is successfully updated
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -1740,26 +1789,24 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Gets the users.
      *
-     * @return the users
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @GET
     @Path("/users")
     @Produces("application/json")
     @AuthorizationAction("/permission/admin/manage/getUsers")
-    public UserInfoBean[] getUsers()
+    public Response getUsers()
             throws RestAPIException {
 
         StratosUserManager stratosUserManager = new StratosUserManager();
-        List<UserInfoBean> userList;
 
         try {
-            userList = stratosUserManager.getAllUsers(getTenantUserStoreManager());
-
+            List<UserInfoBean> userList = stratosUserManager.getAllUsers(getTenantUserStoreManager());
+            return Response.ok().entity(userList.toArray(new UserInfoBean[userList.size()])).build();
         } catch (UserManagerException e) {
             throw new RestAPIException(e.getMessage());
         }
-        return userList.toArray(new UserInfoBean[userList.size()]);
     }
 
     /**
@@ -1793,7 +1840,7 @@ public class StratosApiV41 extends AbstractApi {
      * Deploy kubernetes host cluster.
      *
      * @param kubernetesCluster the kubernetes cluster
-     * @return the response
+     * @return 201 if the kubernetes cluster is successfully created
      * @throws RestAPIException the rest api exception
      */
     @POST
@@ -1806,7 +1853,7 @@ public class StratosApiV41 extends AbstractApi {
 
         StratosApiV41Utils.addKubernetesCluster(kubernetesCluster);
         URI url = uriInfo.getAbsolutePathBuilder().path(kubernetesCluster.getClusterId()).build();
-        return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+        return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
                 String.format("Kubernetes Host Cluster added successfully: [kub-host-cluster] %s",
                         kubernetesCluster.getClusterId()))).build();
     }
@@ -1816,7 +1863,7 @@ public class StratosApiV41 extends AbstractApi {
      *
      * @param kubernetesClusterId the kubernetes cluster id
      * @param kubernetesHost      the kubernetes host
-     * @return the response
+     * @return 201 if the kubernetes host is successfully added
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -1830,7 +1877,7 @@ public class StratosApiV41 extends AbstractApi {
 
         StratosApiV41Utils.addKubernetesHost(kubernetesClusterId, kubernetesHost);
         URI url = uriInfo.getAbsolutePathBuilder().path(kubernetesHost.getHostId()).build();
-        return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+        return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
                 String.format("Kubernetes Host added successfully: [kub-host] %s", kubernetesHost.getHostId())))
                 .build();
     }
@@ -1839,7 +1886,7 @@ public class StratosApiV41 extends AbstractApi {
      * Update kubernetes master.
      *
      * @param kubernetesMaster the kubernetes master
-     * @return the response
+     * @return 200 if the kubernetes master is updated successfully, 404 if the kubernetes master is not found
      * @throws RestAPIException the rest api exception
      */
     @PUT
@@ -1852,7 +1899,7 @@ public class StratosApiV41 extends AbstractApi {
         try {
             StratosApiV41Utils.updateKubernetesMaster(kubernetesMaster);
             URI url = uriInfo.getAbsolutePathBuilder().path(kubernetesMaster.getHostId()).build();
-            return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+            return Response.ok(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                     String.format("Kubernetes Master updated successfully: [kub-master] %s",
                             kubernetesMaster.getHostId()))).build();
         } catch (RestAPIException e) {
@@ -1882,7 +1929,7 @@ public class StratosApiV41 extends AbstractApi {
     /**
      * Gets the kubernetes host clusters.
      *
-     * @return the kubernetes host clusters
+     * @return 200
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1899,7 +1946,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the kubernetes host cluster.
      *
      * @param kubernetesClusterId the kubernetes cluster id
-     * @return the kubernetes host cluster
+     * @return 200 if specified kubernetes host cluster is found, 404 if not
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1920,7 +1967,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the kubernetes hosts of kubernetes cluster.
      *
      * @param kubernetesClusterId the kubernetes cluster id
-     * @return the kubernetes hosts of kubernetes cluster
+     * @return 200 if hosts are found in the specified kubernetes host cluster, 404 if not
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1941,7 +1988,7 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the kubernetes master of kubernetes cluster.
      *
      * @param kubernetesClusterId the kubernetes cluster id
-     * @return the kubernetes master of kubernetes cluster
+     * @return 200 if master is found for specified kubernetes cluster, 404 if not
      * @throws RestAPIException the rest api exception
      */
     @GET
@@ -1962,7 +2009,7 @@ public class StratosApiV41 extends AbstractApi {
      * Un deploy kubernetes host cluster.
      *
      * @param kubernetesClusterId the kubernetes cluster id
-     * @return the response
+     * @return 204 if Kubernetes cluster is successfully removed, 404 if the specified Kubernetes cluster is not found
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -1976,8 +2023,8 @@ public class StratosApiV41 extends AbstractApi {
             StratosApiV41Utils.removeKubernetesCluster(kubernetesClusterId);
         } catch (RestAPIException e) {
             return Response.status(Response.Status.NOT_FOUND)
-                    .entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
-                            String.format("Kubernetes Host Cluster removed successfully: [kub-cluster] %s",
+                    .entity(new SuccessResponseBean(Response.Status.NOT_FOUND.getStatusCode(),
+                            String.format("Could not find specified Kubernetes cluster: [kub-cluster] %s",
                                     kubernetesClusterId))).build();
         }
         return Response.noContent().build();
@@ -1987,7 +2034,8 @@ public class StratosApiV41 extends AbstractApi {
      * Undeploy kubernetes host of kubernetes cluster.
      *
      * @param kubernetesHostId the kubernetes host id
-     * @return the response
+     * @return 200 if hosts are successfully removed from the specified Kubernetes cluster, 404 if specified Kubernetes
+     * cluster is not found.
      * @throws RestAPIException the rest api exception
      */
     @DELETE
@@ -1999,12 +2047,12 @@ public class StratosApiV41 extends AbstractApi {
             @PathParam("hostId") String kubernetesHostId) throws RestAPIException {
         try {
             StratosApiV41Utils.removeKubernetesHost(kubernetesHostId);
+            return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+                    String.format("Kubernetes Host removed successfully: [kub-host] %s", kubernetesHostId)))
+                    .build();
         } catch (RestAPIException e) {
             return Response.status(Response.Status.NOT_FOUND).build();
         }
-        return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
-                String.format("Kubernetes Host removed successfully: [kub-host] %s", kubernetesHostId)))
-                .build();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d42e63ef/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 225382b..9b05ccb 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
@@ -114,7 +114,7 @@ public class StratosApiV41Utils {
 
         try {
             if (log.isDebugEnabled()) {
-                log.debug(String.format("Adding cartridge: [cartridge-type] %s ", cartridgeDefinition.getType()));
+                log.debug(String.format("Updating cartridge: [cartridge-type] %s ", cartridgeDefinition.getType()));
             }
 
             Cartridge cartridgeConfig = createCartridgeConfig(cartridgeDefinition);
@@ -122,7 +122,7 @@ public class StratosApiV41Utils {
             cloudControllerServiceClient.updateCartridge(cartridgeConfig);
 
             if (log.isDebugEnabled()) {
-                log.debug(String.format("Successfully update cartridge: [cartridge-type] %s ",
+                log.debug(String.format("Successfully updated cartridge: [cartridge-type] %s ",
                         cartridgeDefinition.getType()));
             }
         } catch (CloudControllerServiceCartridgeDefinitionNotExistsExceptionException e) {
@@ -971,7 +971,8 @@ public class StratosApiV41Utils {
 
             // Validate whether cartridge group can be removed
             if (!smServiceClient.canCartirdgeGroupBeRemoved(name)) {
-                String message = "Cannot remove cartridge group: [group-name] " + name + " since it is used in another cartridge group or an application";
+                String message = "Cannot remove cartridge group: [group-name] " + name +
+                        " since it is used in another cartridge group or an application";
                 log.error(message);
                 throw new RestAPIException(message);
             }
@@ -980,7 +981,8 @@ public class StratosApiV41Utils {
 
             asServiceClient.undeployServiceGroupDefinition(name);
 
-            // Remove the dependent cartridges and cartridge groups from Stratos Manager cache - done after service group has been removed
+            // Remove the dependent cartridges and cartridge groups from Stratos Manager cache
+            // - done after service group has been removed
             if (serviceGroup.getCartridges() != null) {
                 List<String> cartridgeList = new ArrayList<String>();
                 findCartridgesInServiceGroup(serviceGroup, cartridgeList);
@@ -2107,7 +2109,7 @@ public class StratosApiV41Utils {
                     = AutoscalerServiceClient.getInstance().getDeploymentPolicies();
             return ObjectConverter.convertASStubDeploymentPoliciesToDeploymentPolicies(deploymentPolicies);
         } catch (Exception e) {
-            String message = "Could not get network partitions";
+            String message = "Could not get deployment policies";
             log.error(message);
             throw new RuntimeException(message, e);
         }
@@ -2122,7 +2124,7 @@ public class StratosApiV41Utils {
             throws RestAPIException {
         try {
             if (log.isDebugEnabled()) {
-                log.debug(String.format("Adding deployment policy: [deployment-policy-id] %s ",
+                log.debug(String.format("Updating deployment policy: [deployment-policy-id] %s ",
                         deploymentPolicyDefinitionBean.getId()));
             }
 
@@ -2132,16 +2134,16 @@ public class StratosApiV41Utils {
             AutoscalerServiceClient.getInstance().updateDeploymentPolicy(deploymentPolicy);
 
             if (log.isDebugEnabled()) {
-                log.debug(String.format("DeploymentPolicy updates successfully : [deployment-policy-id] %s ",
+                log.debug(String.format("DeploymentPolicy updated successfully : [deployment-policy-id] %s ",
                         deploymentPolicyDefinitionBean.getId()));
             }
         } catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
             String msg =
-                    "Deployment policy already exist [Deployment-policy-id]" + deploymentPolicyDefinitionBean.getId();
+                    "Deployment policy does not exist [Deployment-policy-id]" + deploymentPolicyDefinitionBean.getId();
             log.error(msg, e);
             throw new RestAPIException(msg);
         } catch (Exception e) {
-            String msg = "Could not add deployment policy";
+            String msg = "Could not update deployment policy";
             log.error(msg, e);
             throw new RestAPIException(msg);
         }