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/03/31 11:21:25 UTC

stratos git commit: Fixing 'Artifact repositories not found for application signup' error when two nested groups are used

Repository: stratos
Updated Branches:
  refs/heads/master bc548b084 -> 6de22b176


Fixing 'Artifact repositories not found for application signup' error when two nested groups are used


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

Branch: refs/heads/master
Commit: 6de22b17678b90c27ae40f6662217ce999b235ca
Parents: bc548b0
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Tue Mar 31 14:51:08 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Tue Mar 31 14:51:08 2015 +0530

----------------------------------------------------------------------
 .../services/impl/AutoscalerServiceImpl.java    | 33 +++++++++++++++-----
 1 file changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/6de22b17/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 780c835..9c2dee9 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
@@ -252,13 +252,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
                     updateArtifactRepositoryList(artifactRepositoryList, cartridgeContexts);
                 }
 
-                GroupContext[] groupContexts = components.getGroupContexts();
-                if (groupContexts != null) {
-                    for (GroupContext groupContext : groupContexts) {
-                        if (groupContext != null) {
-                            updateArtifactRepositoryList(artifactRepositoryList, groupContext.getCartridgeContexts());
-                        }
-                    }
+                CartridgeContext[] cartridgeContextsOfGroups = getCartridgeContextsOfGroupsRecursively(
+                        components.getGroupContexts());
+                if (cartridgeContextsOfGroups != null) {
+                    updateArtifactRepositoryList(artifactRepositoryList, cartridgeContextsOfGroups);
                 }
 
                 ArtifactRepository[] artifactRepositoryArray = artifactRepositoryList.toArray(
@@ -283,6 +280,28 @@ public class AutoscalerServiceImpl implements AutoscalerService {
         }
     }
 
+
+    private CartridgeContext[] getCartridgeContextsOfGroupsRecursively(GroupContext[] passedGroupContexts) {
+
+        List<CartridgeContext> cartridgeContextsList = new ArrayList<CartridgeContext>();
+
+        for(GroupContext groupContext : passedGroupContexts){
+            if(groupContext.getCartridgeContexts() != null){
+                for(CartridgeContext cartridgeContext : groupContext.getCartridgeContexts()){
+
+                    cartridgeContextsList.add(cartridgeContext);
+                }
+            }
+            if(groupContext.getGroupContexts() != null){
+                for(CartridgeContext cartridgeContext : getCartridgeContextsOfGroupsRecursively(groupContext.getGroupContexts())){
+
+                    cartridgeContextsList.add(cartridgeContext);
+                }
+            }
+        }
+        return cartridgeContextsList.toArray(new CartridgeContext[0]);
+    }
+
     private void removeApplicationSignUp(ApplicationContext applicationContext){
         try {
             if (log.isInfoEnabled()) {