You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/04/29 12:08:18 UTC

[01/10] stratos git commit: Changing default error code thrown for RestAPIException to 500

Repository: stratos
Updated Branches:
  refs/heads/master a2e1aa305 -> 48b99b852


Changing default error code thrown for RestAPIException to 500


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

Branch: refs/heads/master
Commit: 3206fe7c60105536e3080be85b039300fc765cf6
Parents: a9d8188
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Tue Apr 28 15:23:42 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:08 2015 +0530

----------------------------------------------------------------------
 .../stratos/rest/endpoint/handlers/CustomExceptionMapper.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/3206fe7c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java
index 759cc20..062a153 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java
@@ -43,7 +43,7 @@ public class CustomExceptionMapper implements ExceptionMapper<RestAPIException>
                 restAPIException.getMessage() : "Error while fulfilling the request";
         // if no specific error specified we are throwing the bad request http status code by default
         Response.Status httpStatus = (restAPIException.getHTTPStatusCode() != null) ?
-                restAPIException.getHTTPStatusCode() : Response.Status.BAD_REQUEST;
+                restAPIException.getHTTPStatusCode() : Response.Status.INTERNAL_SERVER_ERROR;
 
         log.error(errorMessage, restAPIException);
         return Response.status(httpStatus.getStatusCode()).type(MediaType.APPLICATION_JSON).


[05/10] stratos git commit: Add new exceptions to handle specific errors in Autoscaler

Posted by la...@apache.org.
Add new exceptions to handle specific errors in Autoscaler


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

Branch: refs/heads/master
Commit: 40dbcefc5015b94c65292ebc88891222c6f739ee
Parents: 3206fe7
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:08:13 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:09 2015 +0530

----------------------------------------------------------------------
 .../AutoScalingPolicyAlreadyExistException.java        |  7 +++++++
 .../exception/policy/PolicyDoesNotExistException.java  | 13 +++++++++++++
 .../exception/policy/UnremovablePolicyException.java   |  9 +++++++++
 3 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/40dbcefc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/AutoScalingPolicyAlreadyExistException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/AutoScalingPolicyAlreadyExistException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/AutoScalingPolicyAlreadyExistException.java
new file mode 100644
index 0000000..d9f3e5a
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/AutoScalingPolicyAlreadyExistException.java
@@ -0,0 +1,7 @@
+package org.apache.stratos.autoscaler.exception;
+
+public class AutoScalingPolicyAlreadyExistException extends AutoScalerException {
+    public AutoScalingPolicyAlreadyExistException(String msg) {
+        super(msg);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/40dbcefc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/PolicyDoesNotExistException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/PolicyDoesNotExistException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/PolicyDoesNotExistException.java
new file mode 100644
index 0000000..b490f65
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/PolicyDoesNotExistException.java
@@ -0,0 +1,13 @@
+package org.apache.stratos.autoscaler.exception.policy;
+
+import org.apache.stratos.autoscaler.exception.AutoScalerException;
+
+/**
+ *
+ */
+public class PolicyDoesNotExistException extends AutoScalerException {
+
+    public PolicyDoesNotExistException(String msg) {
+        super(msg);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/40dbcefc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/UnremovablePolicyException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/UnremovablePolicyException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/UnremovablePolicyException.java
new file mode 100644
index 0000000..a1a3766
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/UnremovablePolicyException.java
@@ -0,0 +1,9 @@
+package org.apache.stratos.autoscaler.exception.policy;
+
+import org.apache.stratos.autoscaler.exception.AutoScalerException;
+
+public class UnremovablePolicyException extends AutoScalerException {
+    public UnremovablePolicyException(String msg) {
+        super(msg);
+    }
+}


[04/10] stratos git commit: Update autoslcaer service with new Exceptions

Posted by la...@apache.org.
Update autoslcaer service with new Exceptions


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

Branch: refs/heads/master
Commit: 347b49226ac7f9356adb1c55168d0ec65690a4fe
Parents: e5b6ad0
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:10:42 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:09 2015 +0530

----------------------------------------------------------------------
 .../src/main/resources/AutoscalerService.wsdl   | 318 +++++++++++--------
 1 file changed, 185 insertions(+), 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/347b4922/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
index 9f88e16..5b950f5 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax27="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax28="http://partition.common.stratos.apache.org/xsd" xmlns:ax23="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://common.stratos.apache.org/xsd" xmlns:ax21="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax216="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax218="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax221="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://rmi.java/xsd" xmlns:ax213="http://io.java/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax223="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:http="http:/
 /schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax27="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax23="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://common.stratos.apache.org/xsd" xmlns:ax217="http://io.java/xsd" xmlns:ax21="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax216="http://rmi.java/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax220="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://partition.common.stratos.apache.org/xsd" xmlns:ax222="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax211="http://deployment.policy.pojo.au
 toscaler.stratos.apache.org/xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
     <wsdl:types>
-        <xs:schema xmlns:ax214="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://rmi.java/xsd">
+        <xs:schema xmlns:ax218="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://rmi.java/xsd">
             <xs:import namespace="http://io.java/xsd"/>
             <xs:complexType name="RemoteException">
                 <xs:complexContent>
-                    <xs:extension base="ax214:IOException">
+                    <xs:extension base="ax217:IOException">
                         <xs:sequence>
                             <xs:element minOccurs="0" name="cause" nillable="true" type="xs:anyType"/>
                             <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
@@ -21,7 +21,7 @@
                     <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
                     <xs:element minOccurs="0" name="instanceRoundingFactor" type="xs:float"/>
                     <xs:element minOccurs="0" name="isPublic" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax223:LoadThresholds"/>
+                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax29:LoadThresholds"/>
                     <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
                 </xs:sequence>
             </xs:complexType>
@@ -144,8 +144,8 @@
             <xs:complexType name="ServiceGroup">
                 <xs:sequence>
                     <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax221:Dependencies"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax221:ServiceGroup"/>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax27:Dependencies"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax27:ServiceGroup"/>
                     <xs:element minOccurs="0" name="groupscalingEnabled" type="xs:boolean"/>
                     <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
                 </xs:sequence>
@@ -158,15 +158,15 @@
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax26="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax22="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://rmi.java/xsd" xmlns:ax222="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax224="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax211="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax225="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+        <xs:schema xmlns:ax28="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax22="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://rmi.java/xsd" xmlns:ax215="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax221="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax223="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax210="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax226="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
             <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"/>
             <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
             <xs:import namespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
             <xs:import namespace="http://rmi.java/xsd"/>
             <xs:import namespace="http://policy.exception.autoscaler.stratos.apache.org/xsd"/>
             <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
             <xs:import namespace="http://common.stratos.apache.org/xsd"/>
             <xs:element name="AutoscalerServiceApplicationDefinitionException">
                 <xs:complexType>
@@ -189,6 +189,81 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
+            <xs:element name="getApplications">
+                <xs:complexType>
+                    <xs:sequence/>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getApplicationsResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:ApplicationContext"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="addApplication">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax26:ApplicationContext"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getServiceGroup">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getServiceGroupResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax27:ServiceGroup"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getAutoscalingPolicy">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getAutoscalingPolicyResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax29:AutoscalePolicy"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getDeploymentPolicy">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="deploymentPolicyID" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getDeploymentPolicyResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax215:DeploymentPolicy"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getApplication">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getApplicationResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax26:ApplicationContext"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
             <xs:element name="getDeploymentPolicies">
                 <xs:complexType>
                     <xs:sequence/>
@@ -197,49 +272,49 @@
             <xs:element name="getDeploymentPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax27:DeploymentPolicy"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax215:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoscalerServiceRemoteException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ax215:RemoteException"/>
+                        <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ax216:RemoteException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoscalerServiceInvalidDeploymentPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidDeploymentPolicyException" nillable="true" type="ax217:InvalidDeploymentPolicyException"/>
+                        <xs:element minOccurs="0" name="InvalidDeploymentPolicyException" nillable="true" type="ax220:InvalidDeploymentPolicyException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoscalerServiceDeploymentPolicyNotExistsException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="DeploymentPolicyNotExistsException" nillable="true" type="ax217:DeploymentPolicyNotExistsException"/>
+                        <xs:element minOccurs="0" name="DeploymentPolicyNotExistsException" nillable="true" type="ax220:DeploymentPolicyNotExistsException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoscalerServiceInvalidPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax217:InvalidPolicyException"/>
+                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax220:InvalidPolicyException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoscalerServiceCloudControllerConnectionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="CloudControllerConnectionException" nillable="true" type="ax219:CloudControllerConnectionException"/>
+                        <xs:element minOccurs="0" name="CloudControllerConnectionException" nillable="true" type="ax222:CloudControllerConnectionException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="updateDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax27:DeploymentPolicy"/>
+                        <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax215:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -253,7 +328,7 @@
             <xs:element name="addApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax27:ApplicationPolicy"/>
+                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax215:ApplicationPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -267,14 +342,14 @@
             <xs:element name="AutoscalerServiceApplicatioinPolicyNotExistsException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="ApplicatioinPolicyNotExistsException" nillable="true" type="ax217:ApplicatioinPolicyNotExistsException"/>
+                        <xs:element minOccurs="0" name="ApplicatioinPolicyNotExistsException" nillable="true" type="ax220:ApplicatioinPolicyNotExistsException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="updateApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax27:ApplicationPolicy"/>
+                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax215:ApplicationPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -286,7 +361,7 @@
             <xs:element name="getApplicationPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax27:ApplicationPolicy"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax215:ApplicationPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -307,7 +382,7 @@
             <xs:element name="AutoscalerServiceAutoScalerException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax219:AutoScalerException"/>
+                        <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax222:AutoScalerException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -319,7 +394,7 @@
             <xs:element name="getServiceGroupsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax221:ServiceGroup"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax27:ServiceGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -330,10 +405,17 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
+            <xs:element name="AutoscalerServiceAutoScalingPolicyAlreadyExistException">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="AutoScalingPolicyAlreadyExistException" nillable="true" type="ax222:AutoScalingPolicyAlreadyExistException"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
             <xs:element name="addAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax223:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax29:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -352,14 +434,14 @@
             <xs:element name="getAutoScalingPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax223:AutoscalePolicy"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax29:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="updateAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax223:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax29:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -370,6 +452,20 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
+            <xs:element name="AutoscalerServiceUnremovablePolicyException">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="UnremovablePolicyException" nillable="true" type="ax220:UnremovablePolicyException"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="AutoscalerServicePolicyDoesNotExistException">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="PolicyDoesNotExistException" nillable="true" type="ax220:PolicyDoesNotExistException"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
             <xs:element name="removeAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
@@ -424,7 +520,7 @@
             <xs:element name="AutoscalerServiceInvalidArgumentException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax219:InvalidArgumentException"/>
+                        <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax222:InvalidArgumentException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -446,7 +542,7 @@
             <xs:element name="addServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax221:ServiceGroup"/>
+                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax27:ServiceGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -482,14 +578,14 @@
             <xs:element name="AutoscalerServiceDeploymentPolicyAlreadyExistsException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="DeploymentPolicyAlreadyExistsException" nillable="true" type="ax217:DeploymentPolicyAlreadyExistsException"/>
+                        <xs:element minOccurs="0" name="DeploymentPolicyAlreadyExistsException" nillable="true" type="ax220:DeploymentPolicyAlreadyExistsException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addDeployementPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax27:DeploymentPolicy"/>
+                        <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax215:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -517,93 +613,18 @@
             <xs:element name="getApplicationPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax27:ApplicationPolicy"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getApplications">
-                <xs:complexType>
-                    <xs:sequence/>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getApplicationsResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:ApplicationContext"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="addApplication">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax26:ApplicationContext"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getServiceGroup">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getServiceGroupResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax221:ServiceGroup"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getAutoscalingPolicy">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getAutoscalingPolicyResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax223:AutoscalePolicy"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getDeploymentPolicy">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyID" nillable="true" type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getDeploymentPolicyResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax27:DeploymentPolicy"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getApplication">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getApplicationResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax26:ApplicationContext"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax215:ApplicationPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
         </xs:schema>
-        <xs:schema xmlns:ax220="http://common.stratos.apache.org/xsd" xmlns:ax210="http://partition.common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
+        <xs:schema xmlns:ax214="http://partition.common.stratos.apache.org/xsd" xmlns:ax224="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
             <xs:import namespace="http://partition.common.stratos.apache.org/xsd"/>
             <xs:import namespace="http://common.stratos.apache.org/xsd"/>
             <xs:complexType name="DeploymentPolicy">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="deploymentPolicyID" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkPartitions" nillable="true" type="ax28:NetworkPartition"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkPartitions" nillable="true" type="ax214:NetworkPartition"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ApplicationPolicy">
@@ -616,14 +637,14 @@
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax29="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.common.stratos.apache.org/xsd">
+        <xs:schema xmlns:ax213="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.common.stratos.apache.org/xsd">
             <xs:import namespace="http://common.stratos.apache.org/xsd"/>
             <xs:complexType name="NetworkPartition">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="activeByDefault" type="xs:boolean"/>
                     <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
                     <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax28:Partition"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax212:Partition"/>
                     <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
@@ -634,7 +655,7 @@
                     <xs:element minOccurs="0" name="isPublic" type="xs:boolean"/>
                     <xs:element minOccurs="0" name="kubernetesClusterId" nillable="true" type="xs:string"/>
                     <xs:element minOccurs="0" name="partitionMax" type="xs:int"/>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax29:Properties"/>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax24:Properties"/>
                     <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
@@ -669,7 +690,8 @@
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.exception.autoscaler.stratos.apache.org/xsd">
+        <xs:schema xmlns:ax225="http://exception.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.exception.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
             <xs:complexType name="InvalidDeploymentPolicyException">
                 <xs:sequence/>
             </xs:complexType>
@@ -686,6 +708,20 @@
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
+            <xs:complexType name="UnremovablePolicyException">
+                <xs:complexContent>
+                    <xs:extension base="ax222:AutoScalerException">
+                        <xs:sequence/>
+                    </xs:extension>
+                </xs:complexContent>
+            </xs:complexType>
+            <xs:complexType name="PolicyDoesNotExistException">
+                <xs:complexContent>
+                    <xs:extension base="ax222:AutoScalerException">
+                        <xs:sequence/>
+                    </xs:extension>
+                </xs:complexContent>
+            </xs:complexType>
             <xs:complexType name="DeploymentPolicyAlreadyExistsException">
                 <xs:sequence/>
             </xs:complexType>
@@ -706,6 +742,13 @@
                     </xs:extension>
                 </xs:complexContent>
             </xs:complexType>
+            <xs:complexType name="AutoScalingPolicyAlreadyExistException">
+                <xs:complexContent>
+                    <xs:extension base="ax222:AutoScalerException">
+                        <xs:sequence/>
+                    </xs:extension>
+                </xs:complexContent>
+            </xs:complexType>
             <xs:complexType name="InvalidArgumentException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
@@ -719,8 +762,11 @@
     <wsdl:message name="removeAutoScalingPolicyResponse">
         <wsdl:part name="parameters" element="ns:removeAutoScalingPolicyResponse"/>
     </wsdl:message>
-    <wsdl:message name="AutoscalerServiceInvalidPolicyException">
-        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidPolicyException"/>
+    <wsdl:message name="AutoscalerServiceUnremovablePolicyException">
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceUnremovablePolicyException"/>
+    </wsdl:message>
+    <wsdl:message name="AutoscalerServicePolicyDoesNotExistException">
+        <wsdl:part name="parameters" element="ns:AutoscalerServicePolicyDoesNotExistException"/>
     </wsdl:message>
     <wsdl:message name="getAutoScalingPoliciesRequest">
         <wsdl:part name="parameters" element="ns:getAutoScalingPolicies"/>
@@ -743,6 +789,9 @@
     <wsdl:message name="AutoscalerServiceInvalidApplicationPolicyException">
         <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidApplicationPolicyException"/>
     </wsdl:message>
+    <wsdl:message name="AutoscalerServiceInvalidPolicyException">
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidPolicyException"/>
+    </wsdl:message>
     <wsdl:message name="getDeploymentPoliciesRequest">
         <wsdl:part name="parameters" element="ns:getDeploymentPolicies"/>
     </wsdl:message>
@@ -803,15 +852,15 @@
     <wsdl:message name="addAutoScalingPolicyResponse">
         <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"/>
     </wsdl:message>
+    <wsdl:message name="AutoscalerServiceAutoScalingPolicyAlreadyExistException">
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceAutoScalingPolicyAlreadyExistException"/>
+    </wsdl:message>
     <wsdl:message name="addDeployementPolicyRequest">
         <wsdl:part name="parameters" element="ns:addDeployementPolicy"/>
     </wsdl:message>
     <wsdl:message name="AutoscalerServiceInvalidDeploymentPolicyException">
         <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidDeploymentPolicyException"/>
     </wsdl:message>
-    <wsdl:message name="AutoscalerServiceDeploymentPolicyNotExistsException">
-        <wsdl:part name="parameters" element="ns:AutoscalerServiceDeploymentPolicyNotExistsException"/>
-    </wsdl:message>
     <wsdl:message name="AutoscalerServiceDeploymentPolicyAlreadyExistsException">
         <wsdl:part name="parameters" element="ns:AutoscalerServiceDeploymentPolicyAlreadyExistsException"/>
     </wsdl:message>
@@ -848,6 +897,9 @@
     <wsdl:message name="removeDeployementPolicyRequest">
         <wsdl:part name="parameters" element="ns:removeDeployementPolicy"/>
     </wsdl:message>
+    <wsdl:message name="AutoscalerServiceDeploymentPolicyNotExistsException">
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceDeploymentPolicyNotExistsException"/>
+    </wsdl:message>
     <wsdl:message name="updateAutoScalingPolicyRequest">
         <wsdl:part name="parameters" element="ns:updateAutoScalingPolicy"/>
     </wsdl:message>
@@ -903,7 +955,8 @@
         <wsdl:operation name="removeAutoScalingPolicy">
             <wsdl:input message="ns:removeAutoScalingPolicyRequest" wsaw:Action="urn:removeAutoScalingPolicy"/>
             <wsdl:output message="ns:removeAutoScalingPolicyResponse" wsaw:Action="urn:removeAutoScalingPolicyResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:removeAutoScalingPolicyAutoscalerServiceInvalidPolicyException"/>
+            <wsdl:fault message="ns:AutoscalerServiceUnremovablePolicyException" name="AutoscalerServiceUnremovablePolicyException" wsaw:Action="urn:removeAutoScalingPolicyAutoscalerServiceUnremovablePolicyException"/>
+            <wsdl:fault message="ns:AutoscalerServicePolicyDoesNotExistException" name="AutoscalerServicePolicyDoesNotExistException" wsaw:Action="urn:removeAutoScalingPolicyAutoscalerServicePolicyDoesNotExistException"/>
         </wsdl:operation>
         <wsdl:operation name="getAutoScalingPolicies">
             <wsdl:input message="ns:getAutoScalingPoliciesRequest" wsaw:Action="urn:getAutoScalingPolicies"/>
@@ -959,13 +1012,12 @@
         <wsdl:operation name="addAutoScalingPolicy">
             <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"/>
             <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoscalerServiceInvalidPolicyException"/>
+            <wsdl:fault message="ns:AutoscalerServiceAutoScalingPolicyAlreadyExistException" name="AutoscalerServiceAutoScalingPolicyAlreadyExistException" wsaw:Action="urn:addAutoScalingPolicyAutoscalerServiceAutoScalingPolicyAlreadyExistException"/>
         </wsdl:operation>
         <wsdl:operation name="addDeployementPolicy">
             <wsdl:input message="ns:addDeployementPolicyRequest" wsaw:Action="urn:addDeployementPolicy"/>
             <wsdl:fault message="ns:AutoscalerServiceRemoteException" name="AutoscalerServiceRemoteException" wsaw:Action="urn:addDeployementPolicyAutoscalerServiceRemoteException"/>
             <wsdl:fault message="ns:AutoscalerServiceInvalidDeploymentPolicyException" name="AutoscalerServiceInvalidDeploymentPolicyException" wsaw:Action="urn:addDeployementPolicyAutoscalerServiceInvalidDeploymentPolicyException"/>
-            <wsdl:fault message="ns:AutoscalerServiceDeploymentPolicyNotExistsException" name="AutoscalerServiceDeploymentPolicyNotExistsException" wsaw:Action="urn:addDeployementPolicyAutoscalerServiceDeploymentPolicyNotExistsException"/>
             <wsdl:fault message="ns:AutoscalerServiceDeploymentPolicyAlreadyExistsException" name="AutoscalerServiceDeploymentPolicyAlreadyExistsException" wsaw:Action="urn:addDeployementPolicyAutoscalerServiceDeploymentPolicyAlreadyExistsException"/>
         </wsdl:operation>
         <wsdl:operation name="addServiceGroup">
@@ -1062,8 +1114,11 @@
             <wsdl:output>
                 <soap:body use="literal"/>
             </wsdl:output>
-            <wsdl:fault name="AutoscalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"/>
+            <wsdl:fault name="AutoscalerServicePolicyDoesNotExistException">
+                <soap:fault use="literal" name="AutoscalerServicePolicyDoesNotExistException"/>
+            </wsdl:fault>
+            <wsdl:fault name="AutoscalerServiceUnremovablePolicyException">
+                <soap:fault use="literal" name="AutoscalerServiceUnremovablePolicyException"/>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicies">
@@ -1185,8 +1240,8 @@
             <wsdl:output>
                 <soap:body use="literal"/>
             </wsdl:output>
-            <wsdl:fault name="AutoscalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"/>
+            <wsdl:fault name="AutoscalerServiceAutoScalingPolicyAlreadyExistException">
+                <soap:fault use="literal" name="AutoscalerServiceAutoScalingPolicyAlreadyExistException"/>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="addDeployementPolicy">
@@ -1197,9 +1252,6 @@
             <wsdl:fault name="AutoscalerServiceRemoteException">
                 <soap:fault use="literal" name="AutoscalerServiceRemoteException"/>
             </wsdl:fault>
-            <wsdl:fault name="AutoscalerServiceDeploymentPolicyNotExistsException">
-                <soap:fault use="literal" name="AutoscalerServiceDeploymentPolicyNotExistsException"/>
-            </wsdl:fault>
             <wsdl:fault name="AutoscalerServiceDeploymentPolicyAlreadyExistsException">
                 <soap:fault use="literal" name="AutoscalerServiceDeploymentPolicyAlreadyExistsException"/>
             </wsdl:fault>
@@ -1395,8 +1447,11 @@
             <wsdl:output>
                 <soap12:body use="literal"/>
             </wsdl:output>
-            <wsdl:fault name="AutoscalerServiceInvalidPolicyException">
-                <soap12:fault use="literal" name="AutoscalerServiceInvalidPolicyException"/>
+            <wsdl:fault name="AutoscalerServicePolicyDoesNotExistException">
+                <soap12:fault use="literal" name="AutoscalerServicePolicyDoesNotExistException"/>
+            </wsdl:fault>
+            <wsdl:fault name="AutoscalerServiceUnremovablePolicyException">
+                <soap12:fault use="literal" name="AutoscalerServiceUnremovablePolicyException"/>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicies">
@@ -1518,8 +1573,8 @@
             <wsdl:output>
                 <soap12:body use="literal"/>
             </wsdl:output>
-            <wsdl:fault name="AutoscalerServiceInvalidPolicyException">
-                <soap12:fault use="literal" name="AutoscalerServiceInvalidPolicyException"/>
+            <wsdl:fault name="AutoscalerServiceAutoScalingPolicyAlreadyExistException">
+                <soap12:fault use="literal" name="AutoscalerServiceAutoScalingPolicyAlreadyExistException"/>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="addDeployementPolicy">
@@ -1530,9 +1585,6 @@
             <wsdl:fault name="AutoscalerServiceRemoteException">
                 <soap12:fault use="literal" name="AutoscalerServiceRemoteException"/>
             </wsdl:fault>
-            <wsdl:fault name="AutoscalerServiceDeploymentPolicyNotExistsException">
-                <soap12:fault use="literal" name="AutoscalerServiceDeploymentPolicyNotExistsException"/>
-            </wsdl:fault>
             <wsdl:fault name="AutoscalerServiceDeploymentPolicyAlreadyExistsException">
                 <soap12:fault use="literal" name="AutoscalerServiceDeploymentPolicyAlreadyExistsException"/>
             </wsdl:fault>


[06/10] stratos git commit: Adding new exceptions to handle specific errors in rest API

Posted by la...@apache.org.
Adding new exceptions to handle specific errors in rest API


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

Branch: refs/heads/master
Commit: 2fb25df936b633ba56d1f7ceb21284a1a86c6eec
Parents: 8f20bc4
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:14:37 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:10 2015 +0530

----------------------------------------------------------------------
 .../ApplicationPolicyIdIsEmptyException.java    | 70 ++++++++++++++++++++
 .../ApplicationPolicyIsEmptyException.java      | 70 ++++++++++++++++++++
 .../exception/ClusterIdIsEmptyException.java    | 70 ++++++++++++++++++++
 .../exception/InvalidDomainException.java       | 10 +++
 4 files changed, 220 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/2fb25df9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIdIsEmptyException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIdIsEmptyException.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIdIsEmptyException.java
new file mode 100644
index 0000000..a7e0e8f
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIdIsEmptyException.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.exception;
+
+import javax.ws.rs.core.Response;
+
+public class ApplicationPolicyIdIsEmptyException extends RestAPIException {
+
+    private static final long serialVersionUID = 1L;
+
+    private String message;
+    private Response.Status httpStatusCode;
+
+    public ApplicationPolicyIdIsEmptyException() {
+        super();
+    }
+
+    public ApplicationPolicyIdIsEmptyException(String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public ApplicationPolicyIdIsEmptyException(Response.Status httpStatusCode, String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ApplicationPolicyIdIsEmptyException(String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public ApplicationPolicyIdIsEmptyException(Response.Status httpStatusCode, String message) {
+        super(message);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ApplicationPolicyIdIsEmptyException(Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public Response.Status getHTTPStatusCode() {
+        return httpStatusCode;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2fb25df9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIsEmptyException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIsEmptyException.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIsEmptyException.java
new file mode 100644
index 0000000..27488fa
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationPolicyIsEmptyException.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.exception;
+
+import javax.ws.rs.core.Response;
+
+public class ApplicationPolicyIsEmptyException extends RestAPIException {
+
+    private static final long serialVersionUID = 1L;
+
+    private String message;
+    private Response.Status httpStatusCode;
+
+    public ApplicationPolicyIsEmptyException() {
+        super();
+    }
+
+    public ApplicationPolicyIsEmptyException(String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public ApplicationPolicyIsEmptyException(Response.Status httpStatusCode, String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ApplicationPolicyIsEmptyException(String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public ApplicationPolicyIsEmptyException(Response.Status httpStatusCode, String message) {
+        super(message);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ApplicationPolicyIsEmptyException(Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public Response.Status getHTTPStatusCode() {
+        return httpStatusCode;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2fb25df9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ClusterIdIsEmptyException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ClusterIdIsEmptyException.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ClusterIdIsEmptyException.java
new file mode 100644
index 0000000..804031f
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ClusterIdIsEmptyException.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.exception;
+
+import javax.ws.rs.core.Response;
+
+public class ClusterIdIsEmptyException extends RestAPIException {
+
+    private static final long serialVersionUID = 1L;
+
+    private String message;
+    private Response.Status httpStatusCode;
+
+    public ClusterIdIsEmptyException() {
+        super();
+    }
+
+    public ClusterIdIsEmptyException(String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public ClusterIdIsEmptyException(Response.Status httpStatusCode, String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ClusterIdIsEmptyException(String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public ClusterIdIsEmptyException(Response.Status httpStatusCode, String message) {
+        super(message);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ClusterIdIsEmptyException(Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public Response.Status getHTTPStatusCode() {
+        return httpStatusCode;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2fb25df9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/InvalidDomainException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/InvalidDomainException.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/InvalidDomainException.java
new file mode 100644
index 0000000..56125a3
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/InvalidDomainException.java
@@ -0,0 +1,10 @@
+package org.apache.stratos.rest.endpoint.exception;
+
+/**
+ * Created by lahiru on 4/28/15.
+ */
+public class InvalidDomainException extends RestAPIException{
+    public InvalidDomainException(String msg) {
+        super(msg);
+    }
+}


[09/10] stratos git commit: Update rest API with new exceptions, handling status codes better

Posted by la...@apache.org.
Update rest API with new exceptions, handling status codes better


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

Branch: refs/heads/master
Commit: b9d2e3e047064edb2a89f0eabdc8aaf0fbaea80f
Parents: 2fb25df
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:16:00 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:11 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV40Utils.java   |   9 +-
 .../rest/endpoint/api/StratosApiV41.java        | 195 +++++++++++++------
 .../rest/endpoint/api/StratosApiV41Utils.java   | 192 +++++++++---------
 3 files changed, 226 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b9d2e3e0/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
index 2cdea8c..061a988 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
@@ -22,6 +22,7 @@ import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.AutoscalerServiceAutoScalingPolicyAlreadyExistExceptionException;
 import org.apache.stratos.autoscaler.stub.AutoscalerServiceInvalidPolicyExceptionException;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceCartridgeAlreadyExistsExceptionException;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeDefinitionExceptionException;
@@ -164,11 +165,9 @@ public class StratosApiV40Utils {
             } catch (RemoteException e) {
                 log.error(e.getMessage(), e);
                 throw new RestAPIException(e.getMessage(), e);
-            } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-                String message = e.getFaultMessage()
-                        .getInvalidPolicyException().getMessage();
-                log.error(message, e);
-                throw new RestAPIException(message, e);
+            } catch (AutoscalerServiceAutoScalingPolicyAlreadyExistExceptionException e) {
+                log.error(e.getMessage(), e);
+                throw new RestAPIException(e.getMessage(), e);
             }
 
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9d2e3e0/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 c176b9f..1356187 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,6 +20,9 @@ package org.apache.stratos.rest.endpoint.api;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.*;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceNetworkPartitionAlreadyExistsExceptionException;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceNetworkPartitionNotExistsExceptionException;
 import org.apache.stratos.common.beans.*;
 import org.apache.stratos.common.beans.application.ApplicationBean;
 import org.apache.stratos.common.beans.application.ApplicationNetworkPartitionIdListBean;
@@ -38,13 +41,12 @@ import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
 import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
 import org.apache.stratos.common.beans.topology.ApplicationInfoBean;
 import org.apache.stratos.common.beans.topology.ClusterBean;
+import org.apache.stratos.common.exception.InvalidEmailException;
+import org.apache.stratos.manager.service.stub.StratosManagerServiceDomainMappingExceptionException;
 import org.apache.stratos.rest.endpoint.Utils;
 import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
 import org.apache.stratos.rest.endpoint.annotation.SuperTenantService;
-import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyDeployedException;
-import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyExistException;
-import org.apache.stratos.rest.endpoint.exception.RestAPIException;
-import org.apache.stratos.rest.endpoint.exception.TenantNotFoundException;
+import org.apache.stratos.rest.endpoint.exception.*;
 import org.wso2.carbon.context.PrivilegedCarbonContext;
 
 import javax.servlet.http.HttpServletRequest;
@@ -155,21 +157,21 @@ public class StratosApiV41 extends AbstractApi {
     public Response addDeploymentPolicy(
             DeploymentPolicyBean deploymentPolicyDefinitionBean) throws RestAPIException {
 
+        String deploymentPolicyID = deploymentPolicyDefinitionBean.getId();
         try {
-            String deploymentPolicyID = deploymentPolicyDefinitionBean.getId();
             // TODO :: Deployment policy validation
             StratosApiV41Utils.addDeploymentPolicy(deploymentPolicyDefinitionBean);
-            URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
-            return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
-                    String.format("Deployment policy added successfully: " + "[deployment-policy-id] %s",
-                            deploymentPolicyID))).build();
         } catch (RestAPIException e) {
-            if (e.getCause().getMessage().contains("already exists")) {
-                return Response.status(Response.Status.CONFLICT).build();
-            } else {
-                throw e;
-            }
+            throw e;
+        } catch (AutoscalerServiceInvalidDeploymentPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        } catch (AutoscalerServiceDeploymentPolicyAlreadyExistsExceptionException e) {
+            return Response.status(Response.Status.CONFLICT).build();
         }
+        URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
+        return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+                String.format("Deployment policy added successfully: " + "[deployment-policy-id] %s",
+                        deploymentPolicyID))).build();
     }
 
     /**
@@ -231,7 +233,15 @@ public class StratosApiV41 extends AbstractApi {
         String deploymentPolicyID = deploymentPolicyDefinitionBean.getId();
         // TODO :: Deployment policy validation
 
-        StratosApiV41Utils.updateDeploymentPolicy(deploymentPolicyDefinitionBean);
+        try {
+            StratosApiV41Utils.updateDeploymentPolicy(deploymentPolicyDefinitionBean);
+        } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        } catch (AutoscalerServiceInvalidDeploymentPolicyExceptionException e) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        } catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
         URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
         return Response.ok(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Deployment policy updated successfully: " + "[deployment-policy-id] %s",
@@ -253,7 +263,11 @@ public class StratosApiV41 extends AbstractApi {
     public Response removeDeploymentPolicy(
             @PathParam("depolymentPolicyID") String deploymentPolicyID) throws RestAPIException {
 
-        StratosApiV41Utils.removeDeploymentPolicy(deploymentPolicyID);
+        try {
+            StratosApiV41Utils.removeDeploymentPolicy(deploymentPolicyID);
+        } catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
         URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
         return Response.ok(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Deployment policy removed successfully: " + "[deployment-policy-id] %s",
@@ -517,15 +531,13 @@ public class StratosApiV41 extends AbstractApi {
     public Response addNetworkPartition(
             NetworkPartitionBean networkPartitionBean) throws RestAPIException {
         String networkPartitionId = networkPartitionBean.getId();
-        NetworkPartitionBean networkPartition = StratosApiV41Utils.getNetworkPartition(networkPartitionId);
-        if (networkPartition != null) {
-            String msg = String
-                    .format("Network partition already exists: [network-partition-id] %s", networkPartitionId);
-            log.warn(msg);
+        try {
+            StratosApiV41Utils.addNetworkPartition(networkPartitionBean);
+        } catch (CloudControllerServiceNetworkPartitionAlreadyExistsExceptionException e) {
             return Response.status(Response.Status.CONFLICT)
-                    .entity(new ErrorResponseBean(Response.Status.CONFLICT.getStatusCode(), msg)).build();
+                    .entity(new ErrorResponseBean(Response.Status.CONFLICT.getStatusCode(), e.getLocalizedMessage()))
+                    .build();
         }
-        StratosApiV41Utils.addNetworkPartition(networkPartitionBean);
         URI url = uriInfo.getAbsolutePathBuilder().path(networkPartitionId).build();
         return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
                 String.format("Network partition added successfully: [network-partition] %s", networkPartitionId)))
@@ -586,11 +598,12 @@ public class StratosApiV41 extends AbstractApi {
     @AuthorizationAction("/permission/protected/manage/removeNetworkPartition")
     public Response removeNetworkPartition(
             @PathParam("networkPartitionId") String networkPartitionId) throws RestAPIException {
-        NetworkPartitionBean networkPartition = StratosApiV41Utils.getNetworkPartition(networkPartitionId);
-        if (networkPartition == null) {
+
+        try {
+            StratosApiV41Utils.removeNetworkPartition(networkPartitionId);
+        } catch (CloudControllerServiceNetworkPartitionNotExistsExceptionException e) {
             return Response.status(Response.Status.NOT_FOUND).build();
         }
-        StratosApiV41Utils.removeNetworkPartition(networkPartitionId);
         return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Network Partition deleted successfully: [network-partition] %s",
                         networkPartitionId))).build();
@@ -746,11 +759,11 @@ public class StratosApiV41 extends AbstractApi {
                     String.format("Application policy added successfully: [application-policy] %s",
                             applicationPolicy.getId()))).build();
         } catch (RestAPIException e) {
-            if (e.getMessage().contains("already exists")) {
-                return Response.status(Response.Status.CONFLICT).build();
-            } else {
-                throw e;
-            }
+            throw e;
+        } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        } catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
         }
     }
 
@@ -768,12 +781,15 @@ public class StratosApiV41 extends AbstractApi {
     @AuthorizationAction("/permission/protected/manage/getApplicationPolicy")
     public Response getApplicationPolicy(
             @PathParam("applicationPolicyId") String applicationPolicyId) throws RestAPIException {
-        ApplicationPolicyBean applicationPolicyBean = StratosApiV41Utils.getApplicationPolicy(applicationPolicyId);
-        if (applicationPolicyBean == null) {
-            return Response.status(Response.Status.NOT_FOUND).build();
+        try {
+            ApplicationPolicyBean applicationPolicyBean = StratosApiV41Utils.getApplicationPolicy(applicationPolicyId);
+            if (applicationPolicyBean == null) {
+                return Response.status(Response.Status.NOT_FOUND).build();
+            }
+            return Response.ok(applicationPolicyBean).build();
+        } catch (ApplicationPolicyIdIsEmptyException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
         }
-
-        return Response.ok(applicationPolicyBean).build();
     }
 
     /**
@@ -811,11 +827,16 @@ public class StratosApiV41 extends AbstractApi {
     @AuthorizationAction("/permission/admin/manage/removeApplicationPolicy")
     public Response removeApplicationPolicy(
             @PathParam("applicationPolicyId") String applicationPolicyId) throws RestAPIException {
-
-        StratosApiV41Utils.removeApplicationPolicy(applicationPolicyId);
-        return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
-                String.format("Application policy deleted successfully: [application-policy] %s",
-                        applicationPolicyId))).build();
+        try {
+            StratosApiV41Utils.removeApplicationPolicy(applicationPolicyId);
+            return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+                    String.format("Application policy deleted successfully: [application-policy] %s",
+                            applicationPolicyId))).build();
+        } catch (ApplicationPolicyIdIsEmptyException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        }
     }
 
     /**
@@ -833,7 +854,13 @@ public class StratosApiV41 extends AbstractApi {
     public Response updateApplicationPolicy(
             ApplicationPolicyBean applicationPolicy) throws RestAPIException {
 
-        StratosApiV41Utils.updateApplicationPolicy(applicationPolicy);
+        try {
+            StratosApiV41Utils.updateApplicationPolicy(applicationPolicy);
+        } catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        } catch (AutoscalerServiceApplicatioinPolicyNotExistsExceptionException e) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
         return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Application policy updated successfully: [application-policy] %s",
                         applicationPolicy.getId()))).build();
@@ -946,7 +973,11 @@ public class StratosApiV41 extends AbstractApi {
     public Response addDomainMappings(
             @PathParam("applicationId") String applicationId, ApplicationDomainMappingsBean domainMappingsBean)
             throws RestAPIException {
-        StratosApiV41Utils.addApplicationDomainMappings(applicationId, domainMappingsBean);
+        try {
+            StratosApiV41Utils.addApplicationDomainMappings(applicationId, domainMappingsBean);
+        } catch (StratosManagerServiceDomainMappingExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        }
         List<DomainMappingBean> mappings = domainMappingsBean.getDomainMappings();
         List<String> domainMappingList = new ArrayList<String>();
         for (DomainMappingBean domainMappingBean : mappings) {
@@ -974,7 +1005,11 @@ public class StratosApiV41 extends AbstractApi {
     public Response removeDomainMappings(
             @PathParam("applicationId") String applicationId, ApplicationDomainMappingsBean domainMapppingsBean)
             throws RestAPIException {
-        StratosApiV41Utils.removeApplicationDomainMappings(applicationId, domainMapppingsBean);
+        try {
+            StratosApiV41Utils.removeApplicationDomainMappings(applicationId, domainMapppingsBean);
+        } catch (StratosManagerServiceDomainMappingExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        }
         List<DomainMappingBean> mappings = domainMapppingsBean.getDomainMappings();
         List<String> domainMappingList = new ArrayList<String>();
         for (DomainMappingBean domainMappingBean : mappings) {
@@ -999,9 +1034,14 @@ public class StratosApiV41 extends AbstractApi {
     @AuthorizationAction("/permission/protected/manage/getDomainMappings")
     public Response getDomainMappings(
             @PathParam("applicationId") String applicationId) throws RestAPIException {
-        List<DomainMappingBean> domainMappingsBeanList = StratosApiV41Utils.getApplicationDomainMappings(applicationId);
-        if (domainMappingsBeanList == null || domainMappingsBeanList.isEmpty()) {
-            return Response.status(Response.Status.NOT_FOUND).build();
+        List<DomainMappingBean> domainMappingsBeanList = null;
+        try {
+            domainMappingsBeanList = StratosApiV41Utils.getApplicationDomainMappings(applicationId);
+            if (domainMappingsBeanList == null || domainMappingsBeanList.isEmpty()) {
+                return Response.status(Response.Status.NOT_FOUND).build();
+            }
+        } catch (StratosManagerServiceDomainMappingExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
         }
 
         DomainMappingBean[] domainMappingsBeans = domainMappingsBeanList
@@ -1159,12 +1199,12 @@ public class StratosApiV41 extends AbstractApi {
             return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
                     String.format("Autoscaling policy added successfully: [autoscale-policy] %s",
                             autoscalePolicy.getId()))).build();
+        } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        } catch (AutoscalerServiceAutoScalingPolicyAlreadyExistExceptionException e) {
+            return Response.status(Response.Status.CONFLICT).build();
         } catch (RestAPIException e) {
-            if (e.getMessage().contains("already exists")) {
-                return Response.status(Response.Status.CONFLICT).build();
-            } else {
-                throw e;
-            }
+            throw e;
         }
     }
 
@@ -1183,7 +1223,11 @@ public class StratosApiV41 extends AbstractApi {
     public Response updateAutoscalingPolicy(
             AutoscalePolicyBean autoscalePolicy) throws RestAPIException {
 
-        StratosApiV41Utils.updateAutoscalingPolicy(autoscalePolicy);
+        try {
+            StratosApiV41Utils.updateAutoscalingPolicy(autoscalePolicy);
+        } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
+        }
         return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Autoscaling policy updated successfully: [autoscale-policy] %s",
                         autoscalePolicy.getId()))).build();
@@ -1204,7 +1248,11 @@ public class StratosApiV41 extends AbstractApi {
     public Response updateNetworkPartition(
             NetworkPartitionBean networkPartition) throws RestAPIException {
 
-        StratosApiV41Utils.updateNetworkPartition(networkPartition);
+        try {
+            StratosApiV41Utils.updateNetworkPartition(networkPartition);
+        } catch (CloudControllerServiceNetworkPartitionNotExistsExceptionException e) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
         return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Network Partition updated successfully: [network-partition] %s",
                         networkPartition.getId()))).build();
@@ -1225,7 +1273,14 @@ public class StratosApiV41 extends AbstractApi {
     public Response removeAutoscalingPolicy(
             @PathParam("autoscalingPolicyId") String autoscalingPolicyId) throws RestAPIException {
 
-        StratosApiV41Utils.removeAutoscalingPolicy(autoscalingPolicyId);
+        try {
+            StratosApiV41Utils.removeAutoscalingPolicy(autoscalingPolicyId);
+        } catch (AutoscalerServiceUnremovablePolicyExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponseBean(
+                    Response.Status.NOT_ACCEPTABLE.getStatusCode(), e.getMessage())).build();
+        } catch (AutoscalerServicePolicyDoesNotExistExceptionException e) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
         return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
                 String.format("Autoscaling policy deleted successfully: [autoscale-policy] %s",
                         autoscalingPolicyId))).build();
@@ -1246,12 +1301,15 @@ public class StratosApiV41 extends AbstractApi {
     @AuthorizationAction("/permission/admin/manage/cluster")
     public Response getCluster(
             @PathParam("clusterId") String clusterId) throws RestAPIException {
-
-        ClusterBean clusterBean = StratosApiV41Utils.getClusterInfo(clusterId);
-        if (clusterBean == null) {
-            return Response.status(Response.Status.NOT_FOUND).build();
-        } else {
-            return Response.ok().entity(clusterBean).build();
+        try {
+            ClusterBean clusterBean = StratosApiV41Utils.getClusterInfo(clusterId);
+            if (clusterBean == null) {
+                return Response.status(Response.Status.NOT_FOUND).build();
+            } else {
+                return Response.ok().entity(clusterBean).build();
+            }
+        } catch (ClusterIdIsEmptyException e) {
+            return Response.status(Response.Status.BAD_REQUEST).build();
         }
     }
 
@@ -1274,11 +1332,18 @@ public class StratosApiV41 extends AbstractApi {
     public Response addTenant(
             org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean) throws RestAPIException {
 
-        StratosApiV41Utils.addTenant(tenantInfoBean);
+        try {
+            StratosApiV41Utils.addTenant(tenantInfoBean);
+
+        } catch (InvalidEmailException e) {
+            Response.status(Response.Status.BAD_REQUEST).build();
+        } catch (InvalidDomainException e) {
+            Response.status(Response.Status.BAD_REQUEST).build();
+        }
         URI url = uriInfo.getAbsolutePathBuilder().path(tenantInfoBean.getTenantDomain()).build();
         return Response.created(url).entity(
-                new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
-                        String.format("Tenant added successfully: [tenant] %s", tenantInfoBean.getTenantDomain()))).build();
+                new SuccessResponseBean(Response.Status.CREATED.getStatusCode(), String.format(
+                        "Tenant added successfully: [tenant] %s", tenantInfoBean.getTenantDomain()))).build();
     }
 
     /**
@@ -1300,6 +1365,8 @@ public class StratosApiV41 extends AbstractApi {
             StratosApiV41Utils.updateExistingTenant(tenantInfoBean);
         } catch (TenantNotFoundException ex) {
             Response.status(Response.Status.NOT_FOUND).build();
+        } catch (InvalidEmailException e) {
+            Response.status(Response.Status.BAD_REQUEST).build();
         } catch (Exception e) {
             String msg = "Error in updating tenant " + tenantInfoBean.getTenantDomain();
             log.error(msg, e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9d2e3e0/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 87b628f..aafaf66 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
@@ -57,8 +57,10 @@ import org.apache.stratos.common.beans.topology.GroupInstanceBean;
 import org.apache.stratos.common.client.AutoscalerServiceClient;
 import org.apache.stratos.common.client.CloudControllerServiceClient;
 import org.apache.stratos.common.client.StratosManagerServiceClient;
+import org.apache.stratos.common.exception.InvalidEmailException;
 import org.apache.stratos.common.util.ClaimsMgtUtil;
 import org.apache.stratos.common.util.CommonUtil;
+import org.apache.stratos.manager.service.stub.StratosManagerServiceDomainMappingExceptionException;
 import org.apache.stratos.manager.service.stub.domain.application.signup.ApplicationSignUp;
 import org.apache.stratos.manager.service.stub.domain.application.signup.ArtifactRepository;
 import org.apache.stratos.manager.service.stub.domain.application.signup.DomainMapping;
@@ -73,10 +75,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.rest.endpoint.ServiceHolder;
-import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyDeployedException;
-import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyExistException;
-import org.apache.stratos.rest.endpoint.exception.RestAPIException;
-import org.apache.stratos.rest.endpoint.exception.TenantNotFoundException;
+import org.apache.stratos.rest.endpoint.exception.*;
 import org.apache.stratos.rest.endpoint.util.converter.ObjectConverter;
 import org.wso2.carbon.context.CarbonContext;
 import org.wso2.carbon.context.PrivilegedCarbonContext;
@@ -322,7 +321,8 @@ public class StratosApiV41Utils {
         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);
         }
 
 
@@ -551,7 +551,9 @@ public class StratosApiV41Utils {
 
     // Util methods for Autoscaling policies
 
-    public static void addAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean) throws RestAPIException {
+    public static void addAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean) throws RestAPIException,
+            AutoscalerServiceInvalidPolicyExceptionException,
+            AutoscalerServiceAutoScalingPolicyAlreadyExistExceptionException {
 
         log.info(String.format("Adding autoscaling policy: [id] %s", autoscalePolicyBean.getId()));
 
@@ -562,26 +564,22 @@ public class StratosApiV41Utils {
                     convertToCCAutoscalerPojo(autoscalePolicyBean);
 
             try {
-                autoscalerServiceClient
-                        .addAutoscalingPolicy(autoscalePolicy);
+                autoscalerServiceClient.addAutoscalingPolicy(autoscalePolicy);
             } catch (RemoteException e) {
                 log.error(e.getMessage(), e);
                 throw new RestAPIException(e.getMessage(), e);
-            } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-                String message = e.getFaultMessage()
-                        .getInvalidPolicyException().getMessage();
-                log.error(message, e);
-                throw new RestAPIException(message, e);
             }
         }
     }
 
-    public static void addApplicationPolicy(ApplicationPolicyBean applicationPolicyBean) throws RestAPIException {
+    public static void addApplicationPolicy(ApplicationPolicyBean applicationPolicyBean) throws RestAPIException,
+            AutoscalerServiceInvalidPolicyExceptionException,
+            AutoscalerServiceInvalidApplicationPolicyExceptionException {
 
         if (applicationPolicyBean == null) {
             String msg = "Application policy bean is null";
             log.error(msg);
-            throw new RestAPIException(msg);
+            throw new ApplicationPolicyIsEmptyException(msg);
         }
 
         AutoscalerServiceClient serviceClient = getAutoscalerServiceClient();
@@ -591,29 +589,23 @@ public class StratosApiV41Utils {
             if (applicationPolicy == null) {
                 String msg = "Application policy is null";
                 log.error(msg);
-                throw new RestAPIException(msg);
+                throw new ApplicationPolicyIsEmptyException(msg);
             }
             serviceClient.addApplicationPolicy(applicationPolicy);
         } catch (RemoteException e) {
             String msg = "Could not add application policy. " + e.getLocalizedMessage();
             log.error(msg, e);
             throw new RestAPIException(msg);
-        } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-            String msg = "Could not add application policy. Invalid policy. " + e.getLocalizedMessage();
-            log.error(msg, e);
-            throw new RestAPIException(msg);
         } catch (AutoscalerServiceRemoteExceptionException e) {
             String msg = "Could not add application policy. " + e.getLocalizedMessage();
             log.error(msg, e);
             throw new RestAPIException(msg);
-        } catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
-            String msg = "Could not add application policy. Invalid application policy. " + e.getLocalizedMessage();
-            log.error(msg, e);
-            throw new RestAPIException(msg);
         }
     }
 
-    public static void updateApplicationPolicy(ApplicationPolicyBean applicationPolicyBean) throws RestAPIException {
+    public static void updateApplicationPolicy(ApplicationPolicyBean applicationPolicyBean) throws RestAPIException,
+            AutoscalerServiceInvalidApplicationPolicyExceptionException,
+            AutoscalerServiceApplicatioinPolicyNotExistsExceptionException {
 
         log.info(String.format("Updating application policy: [id] %s", applicationPolicyBean.getId()));
 
@@ -629,19 +621,10 @@ public class StratosApiV41Utils {
                 String msg = "Could not update application policy" + e.getLocalizedMessage();
                 log.error(msg, e);
                 throw new RestAPIException(msg);
-            } catch (AutoscalerServiceApplicatioinPolicyNotExistsExceptionException e) {
-                String msg = "Could not update application policy. Application policy not exists" +
-                        e.getLocalizedMessage();
-                log.error(msg, e);
-                throw new RestAPIException(msg);
             } catch (AutoscalerServiceRemoteExceptionException e) {
                 String msg = "Could not update application policy" + e.getLocalizedMessage();
                 log.error(msg, e);
                 throw new RestAPIException(msg);
-            } catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
-                String msg = "Could not update application policy. Invalid application policy" + e.getLocalizedMessage();
-                log.error(msg, e);
-                throw new RestAPIException(msg);
             }
         }
     }
@@ -667,39 +650,40 @@ public class StratosApiV41Utils {
         if (applicationPolicyId == null) {
             String msg = "Application policy bean id null";
             log.error(msg);
-            throw new RestAPIException(msg);
+            throw new ApplicationPolicyIdIsEmptyException(msg);
         }
 
         if (StringUtils.isBlank(applicationPolicyId)) {
             String msg = "Application policy id is empty";
             log.error(msg);
-            throw new RestAPIException(msg);
+            throw new ApplicationPolicyIdIsEmptyException(msg);
         }
 
         try {
             AutoscalerServiceClient serviceClient = AutoscalerServiceClient.getInstance();
             ApplicationPolicy applicationPolicy = serviceClient.getApplicationPolicy(applicationPolicyId);
             return ObjectConverter.convertASStubApplicationPolicyToApplicationPolicy(applicationPolicy);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = String.format("Could not get application policy [application-policy-id] %s",
                     applicationPolicyId);
             log.error(message);
-            throw new RuntimeException(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
-    public static void removeApplicationPolicy(String applicationPolicyId) throws RestAPIException {
+    public static void removeApplicationPolicy(String applicationPolicyId) throws RestAPIException,
+            AutoscalerServiceInvalidPolicyExceptionException {
 
         if (applicationPolicyId == null) {
             String msg = "Application policy bean id null";
             log.error(msg);
-            throw new RestAPIException(msg);
+            throw new ApplicationPolicyIdIsEmptyException(msg);
         }
 
         if (StringUtils.isBlank(applicationPolicyId)) {
             String msg = "Application policy id is empty";
             log.error(msg);
-            throw new RestAPIException(msg);
+            throw new ApplicationPolicyIdIsEmptyException(msg);
         }
 
         AutoscalerServiceClient serviceClient = getAutoscalerServiceClient();
@@ -709,14 +693,11 @@ public class StratosApiV41Utils {
             String msg = "Could not remove application policy. " + e.getLocalizedMessage();
             log.error(msg, e);
             throw new RestAPIException(msg);
-        } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-            String msg = "Could not remove application policy. " + e.getLocalizedMessage();
-            log.error(msg, e);
-            throw new RestAPIException(msg);
         }
     }
 
-    public static void updateAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean) throws RestAPIException {
+    public static void updateAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean) throws RestAPIException,
+            AutoscalerServiceInvalidPolicyExceptionException {
 
         log.info(String.format("Updating autoscaling policy: [id] %s", autoscalePolicyBean.getId()));
 
@@ -730,15 +711,13 @@ public class StratosApiV41Utils {
             } catch (RemoteException e) {
                 log.error(e.getMessage(), e);
                 throw new RestAPIException(e.getMessage(), e);
-            } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-                String message = e.getFaultMessage().getInvalidPolicyException().getMessage();
-                log.error(message, e);
-                throw new RestAPIException(message, e);
             }
         }
     }
 
-    public static void removeAutoscalingPolicy(String autoscalePolicyId) throws RestAPIException {
+    public static void removeAutoscalingPolicy(String autoscalePolicyId) throws RestAPIException,
+            AutoscalerServicePolicyDoesNotExistExceptionException,
+            AutoscalerServiceUnremovablePolicyExceptionException {
 
         log.info(String.format("Removing autoscaling policy: [id] %s", autoscalePolicyId));
 
@@ -750,10 +729,6 @@ public class StratosApiV41Utils {
             } catch (RemoteException e) {
                 log.error(e.getMessage(), e);
                 throw new RestAPIException(e.getMessage(), e);
-            } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-                String message = e.getFaultMessage().getInvalidPolicyException().getMessage();
-                log.error(message, e);
-                throw new RestAPIException(message, e);
             }
         }
     }
@@ -962,7 +937,8 @@ public class StratosApiV41Utils {
         try {
             AutoscalerServiceClient asServiceClient = AutoscalerServiceClient.getInstance();
             ServiceGroup[] serviceGroups = asServiceClient.getServiceGroups();
-            if (serviceGroups == null || serviceGroups.length == 0 || (serviceGroups.length == 1 && serviceGroups[0] == null)) {
+            if (serviceGroups == null || serviceGroups.length == 0 || (serviceGroups.length == 1 && serviceGroups[0]
+                    == null)) {
                 return null;
             }
 
@@ -2003,7 +1979,8 @@ public class StratosApiV41Utils {
     }
 
     public static void addApplicationDomainMappings(
-            String applicationId, ApplicationDomainMappingsBean domainMapppingsBean) throws RestAPIException {
+            String applicationId, ApplicationDomainMappingsBean domainMapppingsBean) throws RestAPIException,
+            StratosManagerServiceDomainMappingExceptionException {
 
         try {
             int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
@@ -2030,7 +2007,7 @@ public class StratosApiV41Utils {
                     }
                 }
             }
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = "Could not add domain mappings: [application-id] " + applicationId;
             log.error(message, e);
             throw new RestAPIException(message, e);
@@ -2053,7 +2030,7 @@ public class StratosApiV41Utils {
 
     public static void removeApplicationDomainMappings(String applicationId,
                                                        ApplicationDomainMappingsBean domainMapppingsBean)
-            throws RestAPIException {
+            throws RestAPIException, StratosManagerServiceDomainMappingExceptionException {
 
         try {
             int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
@@ -2070,14 +2047,15 @@ public class StratosApiV41Utils {
                     }
                 }
             }
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = "Could not remove domain mappings: [application-id] " + applicationId;
             log.error(message, e);
             throw new RestAPIException(message, e);
         }
     }
 
-    public static List<DomainMappingBean> getApplicationDomainMappings(String applicationId) throws RestAPIException {
+    public static List<DomainMappingBean> getApplicationDomainMappings(String applicationId) throws RestAPIException,
+            StratosManagerServiceDomainMappingExceptionException {
         try {
             int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
             List<DomainMappingBean> domainMappingsBeans = new ArrayList<DomainMappingBean>();
@@ -2093,76 +2071,79 @@ public class StratosApiV41Utils {
                 }
             }
             return domainMappingsBeans;
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = "Could not get domain mappings: [application-id] " + applicationId;
             log.error(message, e);
             throw new RestAPIException(message, e);
         }
     }
 
-    public static void addNetworkPartition(NetworkPartitionBean networkPartitionBean) {
+    public static void addNetworkPartition(NetworkPartitionBean networkPartitionBean) throws RestAPIException,
+            CloudControllerServiceNetworkPartitionAlreadyExistsExceptionException {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
             serviceClient.addNetworkPartition(
                     ObjectConverter.convertNetworkPartitionToCCStubNetworkPartition(networkPartitionBean));
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = "Could not add network partition";
             log.error(message);
-            throw new RuntimeException(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
-    public static NetworkPartitionBean[] getNetworkPartitions() {
+    public static NetworkPartitionBean[] getNetworkPartitions() throws RestAPIException {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
             org.apache.stratos.cloud.controller.stub.domain.NetworkPartition[] networkPartitions =
                     serviceClient.getNetworkPartitions();
             return ObjectConverter.convertCCStubNetworkPartitionsToNetworkPartitions(networkPartitions);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = "Could not get network partitions";
             log.error(message);
-            throw new RuntimeException(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
-    public static void removeNetworkPartition(String networkPartitionId) {
+    public static void removeNetworkPartition(String networkPartitionId) throws RestAPIException,
+            CloudControllerServiceNetworkPartitionNotExistsExceptionException {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
             serviceClient.removeNetworkPartition(networkPartitionId);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = String.format(
                     "Could not remove network partition: [network-partition-id] %s",
                     networkPartitionId);
             log.error(message);
-            throw new RuntimeException(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
-    public static NetworkPartitionBean getNetworkPartition(String networkPartitionId) {
+    public static NetworkPartitionBean getNetworkPartition(String networkPartitionId) throws RestAPIException {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
             org.apache.stratos.cloud.controller.stub.domain.NetworkPartition networkPartition =
                     serviceClient.getNetworkPartition(networkPartitionId);
             return ObjectConverter.convertCCStubNetworkPartitionToNetworkPartition(networkPartition);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = String.format(
                     "Could not get network partition: [network-partition-id] %s",
                     networkPartitionId);
             log.error(message);
-            throw new RuntimeException(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
-    public static void updateNetworkPartition(NetworkPartitionBean networkPartition) {
+    public static void updateNetworkPartition(NetworkPartitionBean networkPartition) throws RestAPIException,
+            CloudControllerServiceNetworkPartitionNotExistsExceptionException {
         try {
             CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance();
             serviceClient.updateNetworkPartition(ObjectConverter.
                     convertNetworkPartitionToCCStubNetworkPartition(networkPartition));
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = String.format("Could not update network partition: [network-partition-id] %s,",
                     networkPartition.getId());
             log.error(message);
-            throw new RuntimeException(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
@@ -2172,7 +2153,9 @@ public class StratosApiV41Utils {
      * @param deployementPolicyDefinitionBean DeploymentPolicyBean
      */
     public static void addDeploymentPolicy(DeploymentPolicyBean deployementPolicyDefinitionBean)
-            throws RestAPIException {
+            throws RestAPIException,
+            AutoscalerServiceDeploymentPolicyAlreadyExistsExceptionException,
+            AutoscalerServiceInvalidDeploymentPolicyExceptionException{
         try {
             if (log.isDebugEnabled()) {
                 log.debug(String.format("Adding deployment policy: [deployment-policy-id] %s ",
@@ -2188,12 +2171,11 @@ public class StratosApiV41Utils {
                 log.debug(String.format("Successfully added deploymentPolicy: [deployment-policy-id] %s ",
                         deployementPolicyDefinitionBean.getId()));
             }
-        } catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
-            String msg =
-                    "Deployment policy already exists [Deployment-policy-id]" + deployementPolicyDefinitionBean.getId();
+        } catch (RemoteException e) {
+            String msg = "Could not add deployment policy.";
             log.error(msg, e);
-            throw new RestAPIException(msg);
-        } catch (Exception e) {
+            throw new RestAPIException(msg, e);
+        } catch (AutoscalerServiceRemoteExceptionException e) {
             String msg = "Could not add deployment policy.";
             log.error(msg, e);
             throw new RestAPIException(msg, e);
@@ -2217,7 +2199,7 @@ public class StratosApiV41Utils {
                 return null;
             }
             deploymentPolicyBean = ObjectConverter.convetCCStubDeploymentPolicytoDeploymentPolicy(deploymentPolicy);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String msg = "Could not find deployment policy: [deployment-policy-id] " + deploymentPolicyID;
             log.error(msg, e);
             throw new RestAPIException(msg);
@@ -2231,15 +2213,15 @@ public class StratosApiV41Utils {
      *
      * @return array of {@link DeploymentPolicyBean}
      */
-    public static DeploymentPolicyBean[] getDeployementPolicies() {
+    public static DeploymentPolicyBean[] getDeployementPolicies() throws RestAPIException {
         try {
             org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy[] deploymentPolicies
                     = AutoscalerServiceClient.getInstance().getDeploymentPolicies();
             return ObjectConverter.convertASStubDeploymentPoliciesToDeploymentPolicies(deploymentPolicies);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String message = "Could not get deployment policies";
             log.error(message);
-            throw new RuntimeException(message, e);
+            throw new RestAPIException(message, e);
         }
     }
 
@@ -2250,7 +2232,9 @@ public class StratosApiV41Utils {
      * @throws RestAPIException
      */
     public static void updateDeploymentPolicy(DeploymentPolicyBean deploymentPolicyDefinitionBean)
-            throws RestAPIException {
+            throws RestAPIException, AutoscalerServiceInvalidPolicyExceptionException,
+            AutoscalerServiceInvalidDeploymentPolicyExceptionException,
+            AutoscalerServiceDeploymentPolicyNotExistsExceptionException {
         try {
             if (log.isDebugEnabled()) {
                 log.debug(String.format("Updating deployment policy: [deployment-policy-id] %s ",
@@ -2266,12 +2250,18 @@ public class StratosApiV41Utils {
                 log.debug(String.format("DeploymentPolicy updated successfully : [deployment-policy-id] %s ",
                         deploymentPolicyDefinitionBean.getId()));
             }
-        } catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
-            String msg =
-                    "Deployment policy does not exist [Deployment-policy-id]" + deploymentPolicyDefinitionBean.getId();
+        } catch (RemoteException e) {
+
+            String msg = "Could not update deployment policy " + e.getLocalizedMessage();
             log.error(msg, e);
             throw new RestAPIException(msg);
-        } catch (Exception e) {
+        } catch (AutoscalerServiceCloudControllerConnectionExceptionException e) {
+
+            String msg = "Could not update deployment policy " + e.getLocalizedMessage();
+            log.error(msg, e);
+            throw new RestAPIException(msg);
+        } catch (AutoscalerServiceRemoteExceptionException e) {
+
             String msg = "Could not update deployment policy " + e.getLocalizedMessage();
             log.error(msg, e);
             throw new RestAPIException(msg);
@@ -2285,10 +2275,10 @@ public class StratosApiV41Utils {
      * @throws RestAPIException
      */
     public static void removeDeploymentPolicy(String deploymentPolicyID)
-            throws RestAPIException {
+            throws RestAPIException, AutoscalerServiceDeploymentPolicyNotExistsExceptionException {
         try {
             AutoscalerServiceClient.getInstance().removeDeploymentPolicy(deploymentPolicyID);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             String msg = "Could not remove deployment policy " + e.getLocalizedMessage();
             log.error(msg, e);
             throw new RestAPIException(msg);
@@ -2298,7 +2288,7 @@ public class StratosApiV41Utils {
 
     public static ClusterBean getClusterInfo(String clusterId) throws RestAPIException {
         if (StringUtils.isEmpty(clusterId)) {
-            throw new RestAPIException("Cluster Id can not be empty");
+            throw new ClusterIdIsEmptyException("Cluster Id can not be empty");
         }
 
         Cluster cluster = TopologyManager.getTopology().getCluster(clusterId);
@@ -2317,14 +2307,13 @@ public class StratosApiV41Utils {
      * @param tenantInfoBean
      * @throws RestAPIException
      */
-    public static void addTenant(org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean) throws RestAPIException {
+    public static void addTenant(org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean) throws RestAPIException,
+            InvalidEmailException {
 
         try {
             CommonUtil.validateEmail(tenantInfoBean.getEmail());
         } catch (Exception e) {
-            String msg = "Invalid email is provided";
-            log.error(msg, e);
-            throw new RestAPIException(msg);
+            throw new InvalidEmailException(e.getMessage());
         }
 
         String tenantDomain = tenantInfoBean.getTenantDomain();
@@ -2333,7 +2322,7 @@ public class StratosApiV41Utils {
         } catch (Exception e) {
             String msg = "Tenant domain validation error for tenant " + tenantDomain;
             log.error(msg, e);
-            throw new RestAPIException(msg);
+            throw new InvalidDomainException(msg);
         }
 
         UserRegistry userRegistry = (UserRegistry) PrivilegedCarbonContext.getThreadLocalCarbonContext().
@@ -2407,7 +2396,8 @@ public class StratosApiV41Utils {
      * @param tenantInfoBean
      * @throws Exception
      */
-    public static void updateExistingTenant(org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean) throws Exception {
+    public static void updateExistingTenant(org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean) throws
+            Exception, InvalidEmailException {
 
         TenantManager tenantManager = ServiceHolder.getTenantManager();
         UserStoreManager userStoreManager;


[03/10] stratos git commit: Handle specific exceptions correctly in AS service

Posted by la...@apache.org.
Handle specific exceptions correctly in AS service


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

Branch: refs/heads/master
Commit: e5b6ad0ef5b0efd8f527387a918830e1a471a339
Parents: 40dbcef
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:09:45 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:09 2015 +0530

----------------------------------------------------------------------
 .../autoscaler/pojo/policy/PolicyManager.java   | 16 +++++++++-------
 .../autoscaler/services/AutoscalerService.java  |  3 ++-
 .../services/impl/AutoscalerServiceImpl.java    | 20 +++++++++++---------
 3 files changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e5b6ad0e/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
index 997c593..262e5dc 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
@@ -23,8 +23,10 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
+import org.apache.stratos.autoscaler.exception.AutoScalingPolicyAlreadyExistException;
 import org.apache.stratos.autoscaler.exception.policy.InvalidDeploymentPolicyException;
 import org.apache.stratos.autoscaler.exception.policy.InvalidPolicyException;
+import org.apache.stratos.autoscaler.exception.policy.PolicyDoesNotExistException;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy;
@@ -78,15 +80,15 @@ public class PolicyManager {
     }
 
     // Add the policy to information model and persist.
-    public boolean addAutoscalePolicy(AutoscalePolicy policy) throws InvalidPolicyException {
+    public boolean addAutoscalePolicy(AutoscalePolicy policy) throws AutoScalingPolicyAlreadyExistException{
         if (log.isInfoEnabled()) {
             log.info(String.format("Adding autoscaling policy: [id] %s", policy.getId()));
         }
         if (StringUtils.isEmpty(policy.getId())) {
             throw new AutoScalerException("Autoscaling policy id cannot be empty");
         }
-        RegistryManager.getInstance().persistAutoscalerPolicy(policy);
         this.addASPolicyToInformationModel(policy);
+        RegistryManager.getInstance().persistAutoscalerPolicy(policy);
         if (log.isInfoEnabled()) {
             log.info(String.format("Autoscaling policy is added successfully: [id] %s", policy.getId()));
         }
@@ -105,7 +107,7 @@ public class PolicyManager {
         return true;
     }
 
-    public boolean removeAutoscalePolicy(String policyID) throws InvalidPolicyException {
+    public boolean removeAutoscalePolicy(String policyID) {
         if (StringUtils.isEmpty(policyID)) {
             throw new AutoScalerException("Autoscaling policy id cannot be empty");
         }
@@ -183,7 +185,7 @@ public class PolicyManager {
         }
     }
 
-    public void addASPolicyToInformationModel(AutoscalePolicy asPolicy) throws InvalidPolicyException {
+    public void addASPolicyToInformationModel(AutoscalePolicy asPolicy) throws AutoScalingPolicyAlreadyExistException{
         if (!autoscalePolicyListMap.containsKey(asPolicy.getId())) {
             if (log.isDebugEnabled()) {
                 log.debug("Adding autoscaling policy: " + asPolicy.getId());
@@ -192,7 +194,7 @@ public class PolicyManager {
         } else {
             String errMsg = "Specified autoscaling policy [" + asPolicy.getId() + "] already exists";
             log.error(errMsg);
-            throw new InvalidPolicyException(errMsg);
+            throw new AutoScalingPolicyAlreadyExistException(errMsg);
         }
     }
 
@@ -214,14 +216,14 @@ public class PolicyManager {
         }
     }
 
-    public void removeASPolicyInInformationModel(String policyID) throws InvalidPolicyException {
+    public void removeASPolicyInInformationModel(String policyID) throws PolicyDoesNotExistException {
         if (autoscalePolicyListMap.containsKey(policyID)) {
             if (log.isDebugEnabled()) {
                 log.debug("Updating autoscaling policy: " + policyID);
             }
             autoscalePolicyListMap.remove(policyID);
         } else {
-            throw new InvalidPolicyException("No such policy ID [" + policyID + "] exists");
+            throw new PolicyDoesNotExistException("No such policy ID [" + policyID + "] exists");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e5b6ad0e/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
index 1b907d4..7726068 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
@@ -33,6 +33,7 @@ import org.apache.stratos.autoscaler.pojo.ServiceGroup;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.policy.UnremovablePolicyException;
 import org.apache.stratos.common.Properties;
 
 import java.rmi.RemoteException;
@@ -78,7 +79,7 @@ public interface AutoscalerService {
      * @return
      * @throws InvalidPolicyException
      */
-    public boolean removeAutoScalingPolicy(String autoscalingPolicyId) throws InvalidPolicyException;
+    public boolean removeAutoScalingPolicy(String autoscalingPolicyId) throws InvalidPolicyException, UnremovablePolicyException;
 
     /**
      * Add an application

http://git-wip-us.apache.org/repos/asf/stratos/blob/e5b6ad0e/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index d5b66f3..f6523d7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -18,7 +18,6 @@
  */
 package org.apache.stratos.autoscaler.services.impl;
 
-import org.apache.axis2.AxisFault;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,6 +33,7 @@ import org.apache.stratos.autoscaler.context.cluster.ClusterInstanceContext;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.autoscaler.context.partition.network.ClusterLevelNetworkPartitionContext;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
+import org.apache.stratos.autoscaler.exception.AutoScalingPolicyAlreadyExistException;
 import org.apache.stratos.autoscaler.exception.CloudControllerConnectionException;
 import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.exception.application.ApplicationDefinitionException;
@@ -44,6 +44,7 @@ import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
 import org.apache.stratos.autoscaler.pojo.Dependencies;
 import org.apache.stratos.autoscaler.pojo.ServiceGroup;
+import org.apache.stratos.autoscaler.exception.policy.PolicyDoesNotExistException;
 import org.apache.stratos.autoscaler.pojo.policy.PolicyManager;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
@@ -54,7 +55,6 @@ import org.apache.stratos.autoscaler.util.AutoscalerUtil;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidPartitionExceptionException;
 import org.apache.stratos.cloud.controller.stub.domain.MemberContext;
-import org.apache.stratos.cloud.controller.stub.exception.CloudControllerException;
 import org.apache.stratos.common.Properties;
 import org.apache.stratos.common.client.CloudControllerServiceClient;
 import org.apache.stratos.common.client.StratosManagerServiceClient;
@@ -88,7 +88,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
     }
 
     @Override
-    public boolean addAutoScalingPolicy(AutoscalePolicy autoscalePolicy) throws InvalidPolicyException {
+    public boolean addAutoScalingPolicy(AutoscalePolicy autoscalePolicy) throws AutoScalingPolicyAlreadyExistException{
         return PolicyManager.getInstance().addAutoscalePolicy(autoscalePolicy);
     }
 
@@ -98,11 +98,13 @@ public class AutoscalerServiceImpl implements AutoscalerService {
     }
 
     @Override
-    public boolean removeAutoScalingPolicy(String autoscalePolicyId) throws InvalidPolicyException {
-        if (validateAutoScalerPolicy(autoscalePolicyId)) {
+    public boolean removeAutoScalingPolicy(String autoscalePolicyId) throws UnremovablePolicyException,
+            PolicyDoesNotExistException {
+        if (removableAutoScalerPolicy(autoscalePolicyId)) {
             return PolicyManager.getInstance().removeAutoscalePolicy(autoscalePolicyId);
         } else {
-            throw new InvalidPolicyException("This autoscaler policy cannot be removed, since it is used in applications.");
+            throw new UnremovablePolicyException("This autoscaler policy cannot be removed, since it is used in " +
+                    "applications.");
         }
     }
 
@@ -112,7 +114,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
      * @param autoscalePolicyId Auto Scalar policy id boolean
      * @return
      */
-    private boolean validateAutoScalerPolicy(String autoscalePolicyId) {
+    private boolean removableAutoScalerPolicy(String autoscalePolicyId) {
         boolean canRemove = true;
         Collection<ApplicationContext> appContexts = AutoscalerContext.getInstance().getApplicationContexts();
         for (ApplicationContext app : appContexts) {
@@ -825,7 +827,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
 
     @Override
     public void addDeployementPolicy(DeploymentPolicy deploymentPolicy) throws RemoteException,
-            InvalidDeploymentPolicyException, DeploymentPolicyNotExistsException, DeploymentPolicyAlreadyExistsException {
+            InvalidDeploymentPolicyException, DeploymentPolicyAlreadyExistsException {
 
         validateDeploymentPolicy(deploymentPolicy);
 
@@ -852,7 +854,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
         }
     }
 
-    private void validateDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws DeploymentPolicyNotExistsException,
+    private void validateDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws
             InvalidDeploymentPolicyException, RemoteException {
 
         // deployment policy can't be null


[10/10] stratos git commit: Handle newly introduced codes in CLI and add class comment

Posted by la...@apache.org.
Handle newly introduced codes in CLI and add class comment


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

Branch: refs/heads/master
Commit: 48b99b85208b500d9de0b25ffe3499d0f5f63c90
Parents: b9d2e3e
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:16:37 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:11 2015 +0530

----------------------------------------------------------------------
 .../java/org/apache/stratos/cli/RestClient.java | 66 ++++++++++++--------
 1 file changed, 41 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/48b99b85/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
index 2aba654..c022804 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
@@ -1,20 +1,20 @@
 /**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.stratos.cli;
 
@@ -37,6 +37,14 @@ import org.slf4j.LoggerFactory;
 import java.io.IOException;
 import java.lang.reflect.Type;
 
+/**
+ * This class has three types of methods
+ * 1. doPost, doPut, doGet, doDelete
+ * 2. deployEntity, updateEntity, getEntity, listEntity, deleteEntity
+ * 3. executePost, executePut, executeGet, executeDelete
+ *
+ * All the status code handling happens at category #2
+ */
 public class RestClient implements GenericRestClient {
 
     private static final Logger log = LoggerFactory.getLogger(RestClient.class);
@@ -159,6 +167,8 @@ public class RestClient implements GenericRestClient {
             int responseCode = executePost(serviceEndpoint, entityBody);
             if (responseCode == 201 || responseCode == 200) {
                 System.out.println(String.format("Successfully added %s", entityName));
+            } else if (responseCode == 500) {
+                System.out.println("Internal server error occurred");
             }
         } catch (Exception e) {
             String message = String.format("Error in adding %s", entityName);
@@ -172,11 +182,13 @@ public class RestClient implements GenericRestClient {
             int responseCode = executeDelete(serviceEndpoint.replace("{id}", entityId));
             if (responseCode == 404) {
                 System.out.println(String.format("%s not found", StringUtils.capitalize(entityName)));
-            } else if (responseCode >= 200 && responseCode <300) {
-                System.out.println(String.format("Successfully un-deployed %s : %s", entityName,entityId));
+            } else if (responseCode == 500) {
+                System.out.println("Internal server error occurred");
+            } else if (responseCode >= 200 && responseCode < 300) {
+                System.out.println(String.format("Successfully un-deployed %s : %s", entityName, entityId));
             }
         } catch (Exception e) {
-            String message = String.format("Error in un-deploying %s : %s", entityName,entityId);
+            String message = String.format("Error in un-deploying %s : %s", entityName, entityId);
             System.out.println(message);
             log.error(message, e);
         }
@@ -187,7 +199,9 @@ public class RestClient implements GenericRestClient {
             int responseCode = executePut(serviceEndpoint, entityBody);
             if (responseCode == 404) {
                 System.out.println(String.format("%s not found", StringUtils.capitalize(entityName)));
-            } else if (responseCode >= 200 && responseCode <300) {
+            } else if (responseCode == 500) {
+                System.out.println("Internal server error occurred");
+            } else if (responseCode >= 200 && responseCode < 300) {
                 System.out.println(String.format("Successfully updated %s", entityName));
             }
         } catch (Exception e) {
@@ -202,8 +216,10 @@ public class RestClient implements GenericRestClient {
             int responseCode = executeDelete(serviceEndpoint);
             if (responseCode == 404) {
                 System.out.println(String.format("%s not found", StringUtils.capitalize(entityName)));
+            } else if (responseCode == 500) {
+                System.out.println("Internal server error occurred");
             } else if (responseCode >= 200 && responseCode < 300) {
-                System.out.println(String.format("Successfully deleted %s : %s", entityName,identifier));
+                System.out.println(String.format("Successfully deleted %s : %s", entityName, identifier));
             }
         } catch (Exception e) {
             String message = String.format("Error in deleting %s", entityName);
@@ -217,7 +233,7 @@ public class RestClient implements GenericRestClient {
         try {
             return executeGet(serviceEndpoint.replace(identifierPlaceHolder, identifier), responseJsonClass);
         } catch (Exception e) {
-            String message = String.format("Error in getting %s : %s", entityName,identifier);
+            String message = String.format("Error in getting %s : %s", entityName, identifier);
             System.out.println(message);
             log.error(message, e);
             return null;
@@ -228,7 +244,7 @@ public class RestClient implements GenericRestClient {
         try {
             return executeGet(serviceEndpoint.replace(identifierPlaceHolder, identifier), responseType);
         } catch (Exception e) {
-            String message = String.format("Error in getting %s : %s", entityName,identifier);
+            String message = String.format("Error in getting %s : %s", entityName, identifier);
             System.out.println(message);
             log.error(message, e);
             return null;
@@ -260,7 +276,7 @@ public class RestClient implements GenericRestClient {
     private int executePost(String serviceEndpoint, String postBody) throws IOException {
         DefaultHttpClient httpClient = new DefaultHttpClient();
         try {
-            HttpResponse response = doPost(httpClient, getBaseURL()+ serviceEndpoint, postBody);
+            HttpResponse response = doPost(httpClient, getBaseURL() + serviceEndpoint, postBody);
 
             int responseCode = response.getStatusLine().getStatusCode();
             if (responseCode < 200 || responseCode >= 300) {
@@ -302,7 +318,7 @@ public class RestClient implements GenericRestClient {
             response = doGet(httpClient, getBaseURL() + serviceEndpoint);
             int responseCode = response.getStatusLine().getStatusCode();
 
-            if((responseCode >= 400) && (responseCode < 500)) {
+            if ((responseCode >= 400) && (responseCode < 500)) {
                 // Entity not found
                 return null;
             } else if (responseCode < 200 || responseCode >= 300) {


[02/10] stratos git commit: Use new exception, ApplicationAlreadyDeployedException to catch already deployed case

Posted by la...@apache.org.
Use new exception, ApplicationAlreadyDeployedException to catch already deployed case


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

Branch: refs/heads/master
Commit: a9d8188b945456930ac8ea38f7ef8c43063879a0
Parents: a2e1aa3
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Tue Apr 28 14:06:41 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:08 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41.java        | 18 +++--
 .../rest/endpoint/api/StratosApiV41Utils.java   |  5 +-
 .../ApplicationAlreadyDeployedException.java    | 70 ++++++++++++++++++++
 3 files changed, 81 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/a9d8188b/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 5ebf027..c176b9f 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
@@ -41,6 +41,7 @@ import org.apache.stratos.common.beans.topology.ClusterBean;
 import org.apache.stratos.rest.endpoint.Utils;
 import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
 import org.apache.stratos.rest.endpoint.annotation.SuperTenantService;
+import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyDeployedException;
 import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyExistException;
 import org.apache.stratos.rest.endpoint.exception.RestAPIException;
 import org.apache.stratos.rest.endpoint.exception.TenantNotFoundException;
@@ -647,11 +648,8 @@ public class StratosApiV41 extends AbstractApi {
                     String.format("Application added successfully: [application] %s",
                             applicationDefinition.getApplicationId()))).build();
         } catch (RestAPIException e) {
-            if (e.getMessage().contains("already exists")) {
-                return Response.status(Response.Status.CONFLICT).build();
-            } else {
-                throw e;
-            }
+
+            throw e;
         }
     }
 
@@ -718,12 +716,12 @@ public class StratosApiV41 extends AbstractApi {
             StratosApiV41Utils.deployApplication(applicationId, applicationPolicyId);
             return Response.accepted().entity(new SuccessResponseBean(Response.Status.ACCEPTED.getStatusCode(),
                     String.format("Application deployed successfully: [application] %s", applicationId))).build();
+        } catch (ApplicationAlreadyDeployedException e) {
+
+            return Response.status(Response.Status.CONFLICT).build();
         } catch (RestAPIException e) {
-            if (e.getMessage().contains("already in DEPLOYED")) {
-                return Response.status(Response.Status.CONFLICT).build();
-            } else {
-                throw e;
-            }
+
+            throw e;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/a9d8188b/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 35f5f87..87b628f 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
@@ -73,6 +73,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.rest.endpoint.ServiceHolder;
+import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyDeployedException;
 import org.apache.stratos.rest.endpoint.exception.ApplicationAlreadyExistException;
 import org.apache.stratos.rest.endpoint.exception.RestAPIException;
 import org.apache.stratos.rest.endpoint.exception.TenantNotFoundException;
@@ -1073,7 +1074,7 @@ public class StratosApiV41Utils {
      */
     public static void addApplication(ApplicationBean appDefinition, ConfigurationContext ctxt,
                                       String userName, String tenantDomain)
-            throws RestAPIException, ApplicationAlreadyExistException {
+            throws RestAPIException {
 
         if (StringUtils.isBlank(appDefinition.getApplicationId())) {
             String message = "Please specify the application name";
@@ -1291,7 +1292,7 @@ public class StratosApiV41Utils {
                         applicationId,
                         application.getStatus());
                 log.error(message);
-                throw new RestAPIException(message);
+                throw new ApplicationAlreadyDeployedException(message);
             }
 
             // This is a redundant state since there is only CREATED,DEPLOYED state.

http://git-wip-us.apache.org/repos/asf/stratos/blob/a9d8188b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationAlreadyDeployedException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationAlreadyDeployedException.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationAlreadyDeployedException.java
new file mode 100644
index 0000000..22132c4
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/ApplicationAlreadyDeployedException.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.exception;
+
+import javax.ws.rs.core.Response;
+
+public class ApplicationAlreadyDeployedException extends RestAPIException {
+
+    private static final long serialVersionUID = 1L;
+
+    private String message;
+    private Response.Status httpStatusCode;
+
+    public ApplicationAlreadyDeployedException() {
+        super();
+    }
+
+    public ApplicationAlreadyDeployedException(String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public ApplicationAlreadyDeployedException(Response.Status httpStatusCode, String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ApplicationAlreadyDeployedException(String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public ApplicationAlreadyDeployedException(Response.Status httpStatusCode, String message) {
+        super(message);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public ApplicationAlreadyDeployedException(Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public Response.Status getHTTPStatusCode() {
+        return httpStatusCode;
+    }
+
+
+}


[08/10] stratos git commit: Update autoscaler client with new exceptions

Posted by la...@apache.org.
Update autoscaler client with new exceptions


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

Branch: refs/heads/master
Commit: 8f20bc4a83fe140783994c50c23e444f66f88c1f
Parents: 833f719
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:12:53 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:10 2015 +0530

----------------------------------------------------------------------
 .../apache/stratos/common/client/AutoscalerServiceClient.java  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/8f20bc4a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
index 70ae874..2352f68 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
@@ -157,7 +157,7 @@ public class AutoscalerServiceClient {
     }
 
     public boolean addAutoscalingPolicy(AutoscalePolicy autoScalePolicy) throws RemoteException,
-            AutoscalerServiceInvalidPolicyExceptionException {
+            AutoscalerServiceAutoScalingPolicyAlreadyExistExceptionException {
         return stub.addAutoScalingPolicy(autoScalePolicy);
     }
 
@@ -167,7 +167,7 @@ public class AutoscalerServiceClient {
     }
 
     public boolean removeAutoscalingPolicy(String autoScalePolicyId) throws RemoteException,
-            AutoscalerServiceInvalidPolicyExceptionException {
+            AutoscalerServicePolicyDoesNotExistExceptionException, AutoscalerServiceUnremovablePolicyExceptionException {
         return stub.removeAutoScalingPolicy(autoScalePolicyId);
     }
 
@@ -198,7 +198,7 @@ public class AutoscalerServiceClient {
     }
 
     public void addDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws RemoteException,
-            AutoscalerServiceDeploymentPolicyNotExistsExceptionException, AutoscalerServiceRemoteExceptionException,
+            AutoscalerServiceRemoteExceptionException,
             AutoscalerServiceInvalidDeploymentPolicyExceptionException, AutoscalerServiceDeploymentPolicyAlreadyExistsExceptionException {
         stub.addDeployementPolicy(deploymentPolicy);
     }


[07/10] stratos git commit: Adding InvalidEmailException to handle specific error, of invalid email

Posted by la...@apache.org.
Adding InvalidEmailException to handle specific error, of invalid email


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

Branch: refs/heads/master
Commit: 833f7199c8e44e7a1a068c6c711dc6cd56ce6b72
Parents: 347b492
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 29 15:11:38 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 29 15:38:10 2015 +0530

----------------------------------------------------------------------
 .../stratos/common/exception/InvalidEmailException.java     | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/833f7199/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/exception/InvalidEmailException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/exception/InvalidEmailException.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/exception/InvalidEmailException.java
new file mode 100644
index 0000000..fde89b1
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/exception/InvalidEmailException.java
@@ -0,0 +1,9 @@
+package org.apache.stratos.common.exception;
+
+/**
+ * Created by lahiru on 4/28/15.
+ */
+public class InvalidEmailException extends Throwable {
+    public InvalidEmailException(String msg) {
+    }
+}