You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/02/13 19:01:38 UTC
[2/2] stratos git commit: Add deploy policy remove and get REST API
Add deploy policy remove and get REST API
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/96f3fcdc
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/96f3fcdc
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/96f3fcdc
Branch: refs/heads/4.1.0-beta-deployment-policy-fix
Commit: 96f3fcdcf90a3661dab4bcc62ae75fa3f4c788e7
Parents: 2fcbea6
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Fri Feb 13 23:30:59 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Fri Feb 13 23:30:59 2015 +0530
----------------------------------------------------------------------
.../client/CloudControllerServiceClient.java | 8 +
.../rest/endpoint/api/StratosApiV41.java | 39 +-
.../rest/endpoint/api/StratosApiV41Utils.java | 51 +-
.../util/converter/ObjectConverter.java | 4 +
.../main/resources/CloudControllerService.wsdl | 946 +++++++++----------
5 files changed, 555 insertions(+), 493 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/96f3fcdc/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
index de6f2c1..6ea69e2 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
@@ -199,5 +199,13 @@ public class CloudControllerServiceClient {
stub.updateDeployementPolicy(deploymentPolicy);
}
+ public void removeDeploymentPolicy(String deploymentPolicyID)
+ throws CloudControllerServiceDeploymentPolicyNotExistsExceptionException, RemoteException {
+ stub.removeDeployementPolicy(deploymentPolicyID);
+ }
+ public DeploymentPolicy getDeploymentPolicy(String deploymentPolicyID)
+ throws CloudControllerServiceDeploymentPolicyNotExistsExceptionException, RemoteException {
+ return stub.getDeploymentPolicy(deploymentPolicyID);
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/96f3fcdc/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 9a0c052..c080d93 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
@@ -160,7 +160,7 @@ public class StratosApiV41 extends AbstractApi {
/**
* Creates the Deployement Policy Definition.
*
- * @param deploymentPolicyDefinitionBean the cartridge definition bean
+ * @param deploymentPolicyDefinitionBean the deployment policy bean
* @return the response
* @throws RestAPIException the rest api exception
*/
@@ -174,15 +174,6 @@ public class StratosApiV41 extends AbstractApi {
String deploymentPolicyID = deploymentPolicyDefinitionBean.getId();
// TODO :: Deployment policy validation
- DeploymentPolicyBean depploymentPolicy = StratosApiV41Utils.getDeployementPolicy(deploymentPolicyID);
- if (depploymentPolicy != null) {
- String msg =
- String.format("Deployment policy already exists: [Deployment Policy ID] %s", deploymentPolicyID);
- log.warn(msg);
- return Response.status(Response.Status.CONFLICT).entity(new ErrorResponseBean(
- Response.Status.CONFLICT.getStatusCode(), msg)).build();
- }
-
StratosApiV41Utils.addDeploymentPolicy(deploymentPolicyDefinitionBean);
URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
@@ -195,7 +186,7 @@ public class StratosApiV41 extends AbstractApi {
/**
* Updates the Deployment Policy Definition.
*
- * @param deploymentPolicyDefinitionBean the cartridge definition bean
+ * @param deploymentPolicyDefinitionBean the deployment policy bean
* @return the response
* @throws RestAPIException the rest api exception
*/
@@ -214,7 +205,31 @@ public class StratosApiV41 extends AbstractApi {
URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
String.format(
- "Deployment policy added successfully: " +
+ "Deployment policy updated successfully: " +
+ "[deployment-policy-id] %s",
+ deploymentPolicyID))).build();
+ }
+
+ /**
+ * Updates the Deployment Policy Definition.
+ *
+ * @param deploymentPolicyID the deployment policy id
+ * @return the response
+ * @throws RestAPIException the rest api exception
+ */
+ @DELETE
+ @Path("/deploymentPolicies")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/admin/manage/addCartridge")
+ public Response removeDeploymentPolicy(String deploymentPolicyID)
+ throws RestAPIException {
+
+ StratosApiV41Utils.removeDeploymentPolicy(deploymentPolicyID);
+ URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
+ return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+ String.format(
+ "Deployment policy removed successfully: " +
"[deployment-policy-id] %s",
deploymentPolicyID))).build();
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/96f3fcdc/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 7b2c688..2bce1fe 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
@@ -1843,7 +1843,7 @@ public class StratosApiV41Utils {
/**
* Add deployment policy
*
- * @param deployementPolicyDefinitionBean
+ * @param deployementPolicyDefinitionBean DeploymentPolicyBean
*/
public static void addDeploymentPolicy(DeploymentPolicyBean deployementPolicyDefinitionBean)
throws RestAPIException {
@@ -1862,13 +1862,12 @@ public class StratosApiV41Utils {
log.debug(String.format("Successfully added deploymentPolicy: [deployment-policy-id] %s ",
deployementPolicyDefinitionBean.getId()));
}
- }
- catch (CloudControllerServiceDeploymentPolicyAlreadyExistsExceptionException e){
- String msg = "Deployment policy already exist [Deployment-policy-id]"+deployementPolicyDefinitionBean.getId();
+ } catch (CloudControllerServiceDeploymentPolicyAlreadyExistsExceptionException e) {
+ String msg =
+ "Deployment policy already exist [Deployment-policy-id]" + deployementPolicyDefinitionBean.getId();
log.error(msg, e);
throw new RestAPIException(msg);
- }
- catch (Exception e) {
+ } catch (Exception e) {
String msg = "Could not add deployment policy";
log.error(msg, e);
throw new RestAPIException(msg);
@@ -1880,10 +1879,28 @@ public class StratosApiV41Utils {
* @param deploymentPolicyID Deployment policy ID
* @return
*/
- public static DeploymentPolicyBean getDeployementPolicy(String deploymentPolicyID) {
- return null;
+ public static DeploymentPolicyBean getDeployementPolicy(String deploymentPolicyID) throws RestAPIException {
+
+ DeploymentPolicyBean deploymentPolicy = null;
+ try {
+ CloudControllerServiceClient cloudControllerServiceClient = CloudControllerServiceClient.getInstance();
+ deploymentPolicy = ObjectConverter
+ .convetFromCCDeploymentPolicy(cloudControllerServiceClient.getDeploymentPolicy
+ (deploymentPolicyID));
+ } catch (Exception e) {
+ String msg = "Could not find deployment policy [deployment-policy-id" + deploymentPolicyID;
+ log.error(msg, e);
+ throw new RestAPIException(msg);
+ }
+
+ return deploymentPolicy;
}
+ /**
+ * Update deployement policy
+ * @param deploymentPolicyDefinitionBean DeploymentPolicyBean
+ * @throws RestAPIException
+ */
public static void updateDeploymentPolicy(DeploymentPolicyBean deploymentPolicyDefinitionBean)
throws RestAPIException {
try {
@@ -1912,4 +1929,22 @@ public class StratosApiV41Utils {
throw new RestAPIException(msg);
}
}
+
+ /**
+ * Remove deployment policy
+ * @param deploymentPolicyID Deployment policy ID
+ * @throws RestAPIException
+ */
+ public static void removeDeploymentPolicy(String deploymentPolicyID)
+ throws RestAPIException {
+ try {
+ CloudControllerServiceClient cloudControllerServiceClient = CloudControllerServiceClient.getInstance();
+ cloudControllerServiceClient.removeDeploymentPolicy(deploymentPolicyID);
+ }
+ catch(Exception e){
+ String msg = "Could not remove deployment policy";
+ log.error(msg, e);
+ throw new RestAPIException(msg);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/96f3fcdc/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index c488477..aefd9d8 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -1697,4 +1697,8 @@ public class ObjectConverter {
domainMappingBean.setContextPath(domainMapping.getContextPath());
return domainMappingBean;
}
+
+ public static DeploymentPolicyBean convetFromCCDeploymentPolicy(DeploymentPolicy deploymentPolicy) {
+ return null;
+ }
}