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/09/10 15:40:08 UTC

[2/2] stratos git commit: Fixed super admin only un-deploy a multi tenant application

Fixed super admin only un-deploy a multi tenant application


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

Branch: refs/heads/stratos-4.1.x
Commit: 870d4132f840268ca0bf981b69ac32f101131a66
Parents: 81e4f94
Author: gayangunarathne <ga...@wso2.com>
Authored: Thu Sep 10 19:09:26 2015 +0530
Committer: gayangunarathne <ga...@wso2.com>
Committed: Thu Sep 10 19:09:26 2015 +0530

----------------------------------------------------------------------
 .../org/apache/stratos/rest/endpoint/api/StratosApiV41.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/870d4132/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 3f7237f..e7cd8d1 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
@@ -1300,6 +1300,14 @@ public class StratosApiV41 extends AbstractApi {
             throws RestAPIException {
 
         ApplicationBean applicationDefinition = StratosApiV41Utils.getApplication(applicationId);
+        int tenantId= CarbonContext.getThreadLocalCarbonContext().getTenantId();
+        if (applicationDefinition.isMultiTenant() && (tenantId != -1234)) {
+            String message = String.format(
+                    "Multi-tenant applications can only be deployed by super tenant: [application-id] %s",
+                    applicationId);
+            log.error(message);
+            throw new RestAPIException(message);
+        }
         if (applicationDefinition == null) {
             String message = String.format("Application does not exist [application-id] %s", applicationId);
             log.error(message);
@@ -1313,6 +1321,7 @@ public class StratosApiV41 extends AbstractApi {
             return Response.status(Response.Status.CONFLICT).entity(new ResponseMessageBean(
                     ResponseMessageBean.ERROR, message)).build();
         }
+
         StratosApiV41Utils.undeployApplication(applicationId, force);
         return Response.accepted().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
                 String.format("Application undeploy process started successfully: [application-id] %s",