[gatein-commits] gatein SVN: r6937 - in epp/portal/branches/EPP_5_2_Branch: component and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jul 27 10:07:51 EDT 2011


Author: hfnukal
Date: 2011-07-27 10:07:50 -0400 (Wed, 27 Jul 2011)
New Revision: 6937

Modified:
   epp/portal/branches/EPP_5_2_Branch/
   epp/portal/branches/EPP_5_2_Branch/component/
   epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java
Log:
JBEPP-1008 missing caching of categories in ApplicationRegistryService


Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
   - /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400
/portal/branches/decoupled-webos:6214-6243
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784
   + /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784


Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
   - /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784
   + /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784

Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java	2011-07-27 13:42:48 UTC (rev 6936)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java	2011-07-27 14:07:50 UTC (rev 6937)
@@ -54,51 +54,11 @@
 
    public UIApplicationList() throws Exception
    {
-      ApplicationRegistryService service = getApplicationComponent(ApplicationRegistryService.class);
-      String remoteUser = Util.getPortalRequestContext().getRemoteUser();
-      if (remoteUser == null || remoteUser.equals(""))
-         return;
-      UserACL userACL = Util.getUIPortalApplication().getApplicationComponent(UserACL.class);
-
-      PortletComparator portletComparator = new PortletComparator();
-      categories = service.getApplicationCategories(remoteUser);
-
-      Iterator<ApplicationCategory> cateItr = categories.iterator();
-      while (cateItr.hasNext())
-      {
-         ApplicationCategory cate = cateItr.next();
-         List<Application> applications = cate.getApplications();
-         boolean hasPermission = false;
-         List<String> accessPermission = cate.getAccessPermissions();
-         if (accessPermission == null)
-         {
-            accessPermission = new ArrayList<String>();
-         }
-         if (accessPermission.size() == 0)
-         {
-            accessPermission.add(null);
-         }
-         for (String permssion : accessPermission)
-         {
-            hasPermission = userACL.hasPermission(permssion);
-            if (hasPermission)
-               break;
-         }
-
-         if (!hasPermission || applications.size() < 1)
-            cateItr.remove();
-         else
-            Collections.sort(applications, portletComparator);
-      }
-      if (categories.size() > 0)
-         setSelectedCategory(categories.get(0).getName());
-
-      Collections.sort(categories, new PortletCategoryComparator());
    }
 
    public Application getApplication(String id) throws Exception
    {
-      for (ApplicationCategory category : categories)
+      for (ApplicationCategory category : getCategories())
       {
          List<Application> items = category.getApplications();
          for (Application item : items)
@@ -117,7 +77,7 @@
 
    public void setSelectedCategory(String categoryName)
    {
-      for (ApplicationCategory category : categories)
+      for (ApplicationCategory category : getCategories())
       {
          if (category.getName().equals(categoryName))
          {
@@ -155,22 +115,76 @@
 
    public List<ApplicationCategory> getCategories()
    {
-      return categories;
+      try
+      {
+         //TODO: Handle concurrent requests associated with current session
+         if (categories == null)
+         {
+            initAllCategories();
+         }
+         return categories;
+      }
+      catch (Exception ex)
+      {
+         return null;
+      }
    }
 
-   static class PortletCategoryComparator implements Comparator<ApplicationCategory>
+   private void initAllCategories() throws Exception
    {
-      public int compare(ApplicationCategory cat1, ApplicationCategory cat2)
+      String remoteUser = Util.getPortalRequestContext().getRemoteUser();
+      if (remoteUser == null || remoteUser.equals(""))
+      { return; }
+
+      ApplicationRegistryService service = getApplicationComponent(ApplicationRegistryService.class);
+      UserACL userACL = Util.getUIPortalApplication().getApplicationComponent(UserACL.class);
+
+      final Comparator<Application> appComparator = new Comparator<Application>()
       {
-         return cat1.getDisplayName().compareToIgnoreCase(cat2.getDisplayName());
+         public int compare(Application p_1, Application p_2)
+         {
+            return p_1.getDisplayName().compareToIgnoreCase(p_2.getDisplayName());
+         }
+      };
+      final Comparator<ApplicationCategory> cateComparator = new Comparator<ApplicationCategory>()
+      {
+         public int compare(ApplicationCategory p_1, ApplicationCategory p_2)
+         {
+            return p_1.getDisplayName().compareToIgnoreCase(p_2.getDisplayName());
+         }
+      };
+
+      List<ApplicationCategory> allCategories = service.getApplicationCategories(remoteUser);
+      categories = new ArrayList<ApplicationCategory>();
+
+      for (ApplicationCategory category : allCategories)
+      {
+         List<Application> apps = category.getApplications();
+         List<String> accessPermission = category.getAccessPermissions();
+         if(accessPermission == null)
+         {
+            continue;
+         }
+
+         accessCheck:
+         for (String p : accessPermission)
+         {
+            if (userACL.hasPermission(p))
+            {
+               if (apps.size() > 0)
+               {
+                  Collections.sort(apps, appComparator);
+               }
+               categories.add(category);
+            }
+            break accessCheck;
+         }
       }
-   }
 
-   static class PortletComparator implements Comparator<Application>
-   {
-      public int compare(Application p1, Application p2)
+      if (categories.size() > 0)
       {
-         return p1.getDisplayName().compareToIgnoreCase(p2.getDisplayName());
+         Collections.sort(categories, cateComparator);
+         selectedCategory = categories.get(0);
       }
    }
 



More information about the gatein-commits mailing list