Author: mputz
Date: 2013-01-07 06:57:33 -0500 (Mon, 07 Jan 2013)
New Revision: 9035
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationService.java
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceWrapper.java
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationService.java
Log:
Bug 891247 - One-off patch to remove call of GroupHandler.getAllGroups() method during
root user login
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationService.java
===================================================================
---
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationService.java 2013-01-04
15:38:52 UTC (rev 9034)
+++
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationService.java 2013-01-07
11:57:33 UTC (rev 9035)
@@ -20,6 +20,8 @@
package org.exoplatform.portal.mop.navigation;
import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import java.util.List;
/**
* <p>The navigation service takes care of managing the various portal navigations
and their nodes. In order to manage
@@ -48,6 +50,16 @@
NavigationContext loadNavigation(SiteKey key) throws NullPointerException,
NavigationServiceException;
/**
+ * Find and returns navigations of a given type. Method use discretion is advised
+ *
+ * @param type the navigation type
+ * @return all navigations matching type
+ * @throws NullPointerException if the key is null
+ * @throws NavigationServiceException
+ */
+ List<NavigationContext> loadNavigations(SiteType type) throws
NullPointerException, NavigationServiceException;
+
+ /**
* Create, update a navigation. When the navigation state is not null, the navigation
* will be created or updated depending on whether or not the navigation already
exists.
*
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2013-01-04
15:38:52 UTC (rev 9034)
+++
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2013-01-07
11:57:33 UTC (rev 9035)
@@ -21,13 +21,11 @@
import org.exoplatform.portal.mop.Described;
import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.Visible;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.portal.pom.data.MappedAttributes;
-import static org.exoplatform.portal.mop.navigation.Utils.*;
-import static org.exoplatform.portal.pom.config.Utils.split;
-
import org.exoplatform.portal.pom.data.Mapper;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
@@ -37,14 +35,19 @@
import org.gatein.mop.api.workspace.Site;
import org.gatein.mop.api.workspace.Workspace;
import org.gatein.mop.api.workspace.link.PageLink;
-
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import static org.exoplatform.portal.mop.navigation.Utils.objectType;
+import static org.exoplatform.portal.pom.config.Utils.split;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
@@ -93,6 +96,31 @@
return data != null && data != NavigationData.EMPTY ? new
NavigationContext(data) : null;
}
+ @Override
+ public List<NavigationContext> loadNavigations(SiteType type) throws
NullPointerException, NavigationServiceException
+ {
+ if(type == null)
+ {
+ throw new NullPointerException();
+ }
+
+ POMSession session = manager.getSession();
+ ObjectType<Site> objectType = objectType(type);
+ Collection<Site> sites = session.getWorkspace().getSites(objectType);
+
+ List<NavigationContext> navigations = new
LinkedList<NavigationContext>();
+ for(Site site : sites)
+ {
+ Navigation defaultNavigation =
site.getRootNavigation().getChild("default");
+ if(defaultNavigation != null)
+ {
+ SiteKey key = new SiteKey(type, site.getName());
+ navigations.add(new NavigationContext(new NavigationData(key,
defaultNavigation)));
+ }
+ }
+ return navigations;
+ }
+
public void saveNavigation(NavigationContext navigation) throws NullPointerException,
NavigationServiceException
{
if (navigation == null)
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceWrapper.java
===================================================================
---
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceWrapper.java 2013-01-04
15:38:52 UTC (rev 9034)
+++
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceWrapper.java 2013-01-07
11:57:33 UTC (rev 9035)
@@ -23,6 +23,8 @@
import org.exoplatform.portal.mop.EventType;
import org.exoplatform.portal.mop.SiteKey;
import static org.exoplatform.portal.mop.navigation.Utils.*;
+
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.services.cache.CacheService;
import org.exoplatform.services.jcr.RepositoryService;
@@ -34,6 +36,7 @@
import org.gatein.mop.api.workspace.Site;
import org.picocontainer.Startable;
+import java.util.List;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -101,6 +104,12 @@
return service.loadNavigation(key);
}
+ @Override
+ public List<NavigationContext> loadNavigations(SiteType type) throws
NullPointerException, NavigationServiceException
+ {
+ return service.loadNavigations(type);
+ }
+
public void saveNavigation(NavigationContext navigation) throws NullPointerException,
NavigationServiceException
{
boolean created = navigation.data == null;
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java 2013-01-04
15:38:52 UTC (rev 9034)
+++
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java 2013-01-07
11:57:33 UTC (rev 9035)
@@ -19,13 +19,6 @@
package org.exoplatform.portal.mop.user;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
@@ -39,6 +32,12 @@
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.navigation.VisitMode;
import org.exoplatform.services.organization.Group;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -124,38 +123,45 @@
navigations.add(new UserNavigation(this, userNavigation, true));
}
- //
- Collection<?> groups;
- try
+ // Add group navigations
+ if(service.getUserACL().getSuperUser().equals(userName))
{
- if (service.getUserACL().getSuperUser().equals(userName))
+ List<NavigationContext> navCtxs =
service.getNavigationService().loadNavigations(SiteType.GROUP);
+ for(NavigationContext navCtx : navCtxs)
{
- groups =
service.getOrganizationService().getGroupHandler().getAllGroups();
+
if(!navCtx.getKey().getName().equals(service.getUserACL().getGuestsGroup()))
+ {
+ navigations.add(new UserNavigation(this, navCtx, true));
+ }
}
- else
+ }
+ else
+ {
+ Collection<?> groups;
+ try
{
groups =
service.getOrganizationService().getGroupHandler().findGroupsOfUser(userName);
}
- }
- catch (Exception e)
- {
- throw new UserPortalException("Could not retrieve groups", e);
- }
+ catch (Exception e)
+ {
+ throw new UserPortalException("Could not retrieve groups",
e);
+ }
- //
- for (Object group : groups)
- {
- Group m = (Group)group;
- String groupId = m.getId().trim();
- if (!groupId.equals(service.getUserACL().getGuestsGroup()))
+ //
+ for (Object group : groups)
{
- NavigationContext groupNavigation =
service.getNavigationService().loadNavigation(SiteKey.group(groupId));
- if (groupNavigation != null && groupNavigation.getState() !=
null)
+ Group m = (Group)group;
+ String groupId = m.getId().trim();
+ if (!groupId.equals(service.getUserACL().getGuestsGroup()))
{
- navigations.add(new UserNavigation(
- this,
- groupNavigation,
-
service.getUserACL().hasEditPermissionOnNavigation(groupNavigation.getKey())));
+ NavigationContext groupNavigation =
service.getNavigationService().loadNavigation(SiteKey.group(groupId));
+ if (groupNavigation != null && groupNavigation.getState() !=
null)
+ {
+ navigations.add(new UserNavigation(
+ this,
+ groupNavigation,
+
service.getUserACL().hasEditPermissionOnNavigation(groupNavigation.getKey())));
+ }
}
}
}
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationService.java
===================================================================
---
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationService.java 2013-01-04
15:38:52 UTC (rev 9034)
+++
epp/portal/branches/EPP_5_2_2_GA_BZ851985_BZ861377_BZ891247/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationService.java 2013-01-07
11:57:33 UTC (rev 9035)
@@ -21,6 +21,7 @@
import org.exoplatform.portal.mop.Described;
import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.Visibility;
import org.exoplatform.portal.pom.data.MappedAttributes;
import org.gatein.mop.api.workspace.Navigation;
@@ -31,6 +32,7 @@
import javax.jcr.NodeIterator;
import javax.jcr.Session;
import java.util.Iterator;
+import java.util.List;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -44,6 +46,12 @@
assertNull(service.loadNavigation(SiteKey.portal("non_existing")));
}
+ public void testLoadNavigations() throws Exception
+ {
+ List<NavigationContext> navCtxs = service.loadNavigations(SiteType.PORTAL);
+ assertEquals(3, navCtxs.size());
+ }
+
public void testLoadSingleScope() throws Exception
{
NavigationContext nav =
service.loadNavigation(SiteKey.portal("classic"));