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/01/28 08:06:35 UTC
[1/2] stratos git commit: Adding validation for application and
deployement policy
Repository: stratos
Updated Branches:
refs/heads/master bf1e3ed79 -> 3324b0b5d
Adding validation for application and deployement policy
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/17a14f33
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/17a14f33
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/17a14f33
Branch: refs/heads/master
Commit: 17a14f3337f563c17ce54274795b4dca7d18ced8
Parents: 406e650
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Wed Jan 28 12:27:25 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Wed Jan 28 12:27:25 2015 +0530
----------------------------------------------------------------------
.../rest/endpoint/api/StratosApiV41Utils.java | 51 +++++++++++++++++++-
1 file changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17a14f33/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 ec98bb8..ec09fd1 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
@@ -908,6 +908,11 @@ public class StratosApiV41Utils {
String userName, String tenantDomain)
throws RestAPIException {
+ if (StringUtils.isBlank(appDefinition.getApplicationId())) {
+ String message = "Please specify the application name";
+ log.error(message);
+ throw new RestAPIException(message);
+ }
// check if an application with same id already exists
try {
if (AutoscalerServiceClient.getInstance().getApplication(appDefinition.getApplicationId()) != null) {
@@ -918,6 +923,8 @@ public class StratosApiV41Utils {
throw new RestAPIException("Could not read application", e);
}
+ validateApplication(appDefinition);
+
ApplicationContext applicationContext = ObjectConverter.convertApplicationDefinitionToStubApplicationContext(appDefinition);
applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
applicationContext.setTenantDomain(tenantDomain);
@@ -974,7 +981,22 @@ public class StratosApiV41Utils {
}
}
- /**
+ private static void validateApplication(ApplicationBean appDefinition) throws RestAPIException {
+
+ if(StringUtils.isBlank(appDefinition.getAlias())){
+ String message ="Please specify the application alias";
+ log.error(message);
+ throw new RestAPIException(message);
+ }
+ if(appDefinition.getComponents().getGroups().size()==0 && appDefinition.getComponents().getCartridges().size()==0){
+ String message ="No groups or cartridges attach with this application";
+ log.error(message);
+ throw new RestAPIException(message);
+ }
+
+ }
+
+ /**
* Deploy application with a deployment policy.
*
* @param applicationId
@@ -991,6 +1013,12 @@ public class StratosApiV41Utils {
AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
ApplicationContext application = autoscalerServiceClient.getApplication(applicationId);
+
+ if (StringUtils.isBlank(applicationId)) {
+ String message ="Please specify the application id of the application";
+ log.error(message);
+ throw new RestAPIException(message);
+ }
if(application == null) {
String message = String.format("Application is not found: [application-id] %s", applicationId);
log.error(message);
@@ -1002,6 +1030,7 @@ public class StratosApiV41Utils {
throw new RestAPIException(message);
}
+ validateDeploymentPolicy(deploymentPolicy);
org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy stubDeploymentPolicy =
ObjectConverter.convetToASDeploymentPolicyPojo(applicationId, deploymentPolicy);
autoscalerServiceClient.deployApplication(applicationId, stubDeploymentPolicy);
@@ -1022,7 +1051,25 @@ public class StratosApiV41Utils {
}
}
- public static void removeApplication(String applicationId) throws RestAPIException {
+ /**
+ * Validate deployment policy
+ * @param deploymentPolicy
+ */
+ private static void validateDeploymentPolicy(DeploymentPolicyBean deploymentPolicy) throws RestAPIException {
+ if(deploymentPolicy.getApplicationPolicy().getNetworkPartition().size()==0){
+ String message="No network partitions specify with the policy";
+ log.error(message);
+ throw new RestAPIException(message);
+ }
+ if(deploymentPolicy.getChildPolicies().size()==0){
+ String message = "No child policies specify with the policy";
+ log.error(message);
+ throw new RestAPIException(message);
+ }
+
+ }
+
+ public static void removeApplication(String applicationId) throws RestAPIException {
try {
AutoscalerServiceClient asServiceClient = getAutoscalerServiceClient();
[2/2] stratos git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/stratos
Posted by ga...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/stratos
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3324b0b5
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3324b0b5
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3324b0b5
Branch: refs/heads/master
Commit: 3324b0b5d3d0306382150c729c1ba18dd435f829
Parents: 17a14f3 bf1e3ed
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Wed Jan 28 12:27:38 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Wed Jan 28 12:27:38 2015 +0530
----------------------------------------------------------------------
.../mock-iaas-api/WEB-INF/cxf-servlet.xml | 2 +-
.../artifacts/app_single_group.json-para | 64 --------------------
.../artifacts/app_single_group.json-para | 64 --------------------
.../artifacts/app_single_group.json-para | 64 --------------------
.../artifacts/app_single_group.json-para | 64 --------------------
5 files changed, 1 insertion(+), 257 deletions(-)
----------------------------------------------------------------------