stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ud...@apache.org
Subject [1/4] git commit: getApplicationInfo
Date Mon, 20 Oct 2014 12:20:30 GMT
Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping b81a69b24 -> e75aaa3ec


getApplicationInfo


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

Branch: refs/heads/4.0.0-grouping
Commit: ca43f8d476df23f7b876e3017bb69c97b5e0197b
Parents: d6962c9
Author: Udara Liyanage <udara@wso2.com>
Authored: Fri Oct 17 18:24:44 2014 +0530
Committer: Udara Liyanage <udara@wso2.com>
Committed: Mon Oct 20 17:28:41 2014 +0530

----------------------------------------------------------------------
 .../rest/endpoint/bean/ApplicationBean.java     | 18 +++++++
 .../stratos/rest/endpoint/bean/GroupBean.java   | 35 ++++++++++++++
 .../rest/endpoint/services/ServiceUtils.java    | 51 ++++++++++++++++++--
 .../rest/endpoint/services/StratosAdmin.java    | 10 ++++
 4 files changed, 111 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ca43f8d4/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java
new file mode 100644
index 0000000..024664b
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java
@@ -0,0 +1,18 @@
+package org.apache.stratos.rest.endpoint.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by udara on 10/17/14.
+ */
+public class ApplicationBean {
+    public List<GroupBean> groups = null;
+    public String id;
+    public ApplicationBean(){
+        this.groups = new ArrayList<GroupBean>();
+    }
+    public void addGroup(GroupBean groupBean) {
+        this.groups.add(groupBean);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ca43f8d4/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java
new file mode 100644
index 0000000..77736bd
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java
@@ -0,0 +1,35 @@
+/*
+ * 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.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GroupBean {
+    List<GroupBean> subGroups = null;
+    public String alias;
+
+    public GroupBean(){
+        this.subGroups = new ArrayList<GroupBean>();
+    }
+
+    public void addGroup(GroupBean groupBean){
+        subGroups.add(groupBean);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ca43f8d4/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 515a21a..e29fb4c 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -51,12 +51,12 @@ import org.apache.stratos.manager.subscription.SubscriptionData;
 import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
 import org.apache.stratos.manager.utils.ApplicationManagementUtil;
 import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.MemberStatus;
+import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.messaging.util.Constants;
+import org.apache.stratos.rest.endpoint.bean.ApplicationBean;
 import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean;
+import org.apache.stratos.rest.endpoint.bean.GroupBean;
 import org.apache.stratos.rest.endpoint.bean.SubscriptionDomainRequest;
 import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition;
 import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup;
@@ -1578,4 +1578,49 @@ public class ServiceUtils {
 
         log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName);
     }
+
+    public static Object getApplicationInfo(String applicationId, ConfigurationContext configContext)
{
+
+        TopologyManager.acquireReadLock();
+        Application application = TopologyManager.getTopology().getApplication(applicationId);
+        ApplicationBean applicationBean = applicationToBean(application);
+
+        Map<String, ClusterDataHolder> topLevelClusterDataMap  = application.getClusterDataMap();
+        for(Map.Entry<String, ClusterDataHolder> entry : topLevelClusterDataMap.entrySet()){
+            String alias = entry.getKey();
+            ClusterDataHolder clusterDataHolder = entry.getValue();
+            String clusterId = clusterDataHolder.getClusterId();
+            Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterDataHolder.getServiceType()).getCluster(clusterId);
+        }
+
+        Collection<Group> groups = application.getGroups();
+        for(Group group :  groups){
+            GroupBean groupBean = toGroupBean(group);
+            setSubGroups(group, groupBean);
+            applicationBean.addGroup(groupBean);
+        }
+        TopologyManager.releaseReadLock();
+        return null;
+    }
+
+    private static void setSubGroups(Group group, GroupBean groupBean) {
+        Collection<Group> subgroups = group.getGroups();
+        for(Group subGroup : subgroups){
+            GroupBean subGroupBean = toGroupBean(subGroup);
+            setSubGroups(subGroup, subGroupBean);
+            groupBean.addGroup(subGroupBean);
+        }
+    }
+
+    private static GroupBean toGroupBean(Group group) {
+        GroupBean groupBean = new GroupBean();
+        groupBean.alias = group.getUniqueIdentifier();
+        return groupBean;
+    }
+
+    private static ApplicationBean applicationToBean(Application application) {
+        ApplicationBean applicationBean = new ApplicationBean();
+        applicationBean.id = application.getUniqueIdentifier();
+        return applicationBean;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/ca43f8d4/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index d8e5a40..668f9d6 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -449,6 +449,16 @@ public class StratosAdmin extends AbstractAdmin {
         return  Response.ok().entity(subscriptions).build();
     }
 
+
+    @GET
+    @Path("/application/{appId}")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+    public Response getApplicationInfo(@PathParam("appId") String applicationId) throws RestAPIException
{
+        Object application = ServiceUtils.getApplicationInfo(applicationId, getConfigContext());
+        return Response.status(Response.Status.NOT_FOUND).build();
+    }
+
     @GET
     @Path("/cartridge/list")
     @Produces("application/json")


Mime
View raw message