Author: julien_viet
Date: 2010-02-11 15:14:24 -0500 (Thu, 11 Feb 2010)
New Revision: 1647
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/GroupPortalConfigListener.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
Log:
GTNPORTAL-631: Create group site when adding group navigation when the group site does not
exist
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/GroupPortalConfigListener.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/GroupPortalConfigListener.java 2010-02-11
20:04:22 UTC (rev 1646)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/GroupPortalConfigListener.java 2010-02-11
20:14:24 UTC (rev 1647)
@@ -142,18 +142,7 @@
}
// Create the portal from the template
- portalConfigService.createUserPortalConfig(PortalConfig.GROUP_TYPE, groupId,
"group");
-
- // Need to insert the corresponding group site
- PortalConfig cfg = dataStorage.getPortalConfig(PortalConfig.GROUP_TYPE,
groupId);
- if (cfg == null)
- {
- cfg = new PortalConfig(PortalConfig.GROUP_TYPE);
- cfg.setPortalLayout(new Container());
- cfg.setName(groupId);
- dataStorage.create(cfg);
- }
-
+ portalConfigService.createGroupSite(groupId);
}
finally
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-02-11
20:04:22 UTC (rev 1646)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-02-11
20:14:24 UTC (rev 1647)
@@ -172,10 +172,11 @@
* membership is configured from the value returned by {@link
org.exoplatform.portal.config.UserACL#getMakableMT()}
*
* @param remoteUser the user to get the makable navigations
+ * @param withSite true if a site must exist
* @return the list of groups
* @throws Exception any exception
*/
- public List<String> getMakableNavigations(String remoteUser) throws Exception
+ public List<String> getMakableNavigations(String remoteUser, boolean withSite)
throws Exception
{
Collection<Group> groups;
if (remoteUser.equals(userACL_.getSuperUser()))
@@ -191,19 +192,23 @@
List<String> list = new ArrayList<String>();
if (groups != null)
{
- Query<PortalConfig> q = new Query<PortalConfig>("group",
null, PortalConfig.class);
- LazyPageList<PortalConfig> lpl = storage_.find(q);
- Set<String> existingNames = new HashSet<String>();
- for (PortalConfig groupSite : lpl.getAll())
+ Set<String> existingNames = null;
+ if (withSite)
{
- existingNames.add(groupSite.getName());
+ existingNames = new HashSet<String>();
+ Query<PortalConfig> q = new
Query<PortalConfig>("group", null, PortalConfig.class);
+ LazyPageList<PortalConfig> lpl = storage_.find(q);
+ for (PortalConfig groupSite : lpl.getAll())
+ {
+ existingNames.add(groupSite.getName());
+ }
}
//
for (Group group : groups)
{
String groupId = group.getId().trim();
- if (existingNames.contains(groupId))
+ if (existingNames == null || existingNames.contains(groupId))
{
list.add(groupId);
}
@@ -223,8 +228,8 @@
* <li>if not navigation exists for the user site then it creates an empty
navigation</li>
* </ul>
*
- * @param userName
- * @throws Exception
+ * @param userName the user name
+ * @throws Exception a nasty exception
*/
public void createUserSite(String userName) throws Exception
{
@@ -255,6 +260,33 @@
}
/**
+ * Create a group site for the specified group. It will perform the following:
+ * <ul>
+ * <li>create the group site by calling {@link #createUserPortalConfig(String,
String, String)} which may create
+ * a site or not according to the default configuration</li>
+ * <li>if not site exists then it creates a site then it creates an empty
site</li>
+ * </ul>
+ *
+ * @param groupId the group id
+ * @throws Exception a nasty exception
+ */
+ public void createGroupSite(String groupId) throws Exception
+ {
+ // Create the portal from the template
+ createUserPortalConfig(PortalConfig.GROUP_TYPE, groupId, "group");
+
+ // Need to insert the corresponding group site
+ PortalConfig cfg = storage_.getPortalConfig(PortalConfig.GROUP_TYPE, groupId);
+ if (cfg == null)
+ {
+ cfg = new PortalConfig(PortalConfig.GROUP_TYPE);
+ cfg.setPortalLayout(new Container());
+ cfg.setName(groupId);
+ storage_.create(cfg);
+ }
+ }
+
+ /**
* This method should create a the portal config, pages and navigation according to
the template name.
*
* @param siteType the site type
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-02-11
20:04:22 UTC (rev 1646)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-02-11
20:14:24 UTC (rev 1647)
@@ -347,7 +347,7 @@
{
public void execute() throws Exception
{
- Set<String> navigations = new
HashSet<String>(userPortalConfigSer_.getMakableNavigations("root"));
+ Set<String> navigations = new
HashSet<String>(userPortalConfigSer_.getMakableNavigations("root",
false));
Set<String> expectedNavigations =
new HashSet<String>(Arrays.asList("/platform/users",
"/organization/management/human-resources",
"/partners", "/customers",
"/organization/communication",
"/organization/management/executive-board",
@@ -366,7 +366,7 @@
{
public void execute() throws Exception
{
- Set<String> navigations = new
HashSet<String>(userPortalConfigSer_.getMakableNavigations("john"));
+ Set<String> navigations = new
HashSet<String>(userPortalConfigSer_.getMakableNavigations("john",
false));
Set<String> expectedNavigations =
Collections.singleton("/organization/management/executive-board");
assertEquals(expectedNavigations, navigations);
}
@@ -379,7 +379,7 @@
{
public void execute() throws Exception
{
- Set<String> navigations = new
HashSet<String>(userPortalConfigSer_.getMakableNavigations("mary"));
+ Set<String> navigations = new
HashSet<String>(userPortalConfigSer_.getMakableNavigations("mary",
false));
Set<String> expectedNavigations = Collections.emptySet();
assertEquals(expectedNavigations, navigations);
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java 2010-02-11
20:04:22 UTC (rev 1646)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java 2010-02-11
20:14:24 UTC (rev 1647)
@@ -99,7 +99,7 @@
}
else
{
- listGroup = dataService.getMakableNavigations(pContext.getRemoteUser());
+ listGroup = dataService.getMakableNavigations(pContext.getRemoteUser(), false);
}
if (listGroup == null)
@@ -146,6 +146,13 @@
return;
}
+ // Create group when it does not exist
+ if (dataService.getPortalConfig("group", ownerId) == null)
+ {
+ UserPortalConfigService configService =
uicomp.getApplicationComponent(UserPortalConfigService.class);
+ configService.createGroupSite(ownerId);
+ }
+
// create navigation for group
dataService.create(pageNav);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-02-11
20:04:22 UTC (rev 1646)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-02-11
20:14:24 UTC (rev 1647)
@@ -153,7 +153,7 @@
//TODO: This following line is fixed for bug PORTAL-2127
uiListPermissionSelector.getChild(UIFormPopupWindow.class).setId("UIPageFormPopupGroupMembershipSelector");
- List<String> groups =
configService.getMakableNavigations(pcontext.getRemoteUser());
+ List<String> groups =
configService.getMakableNavigations(pcontext.getRemoteUser(), true);
if (groups.size() > 0)
{
ownerTypes.add(new SelectItemOption<String>(PortalConfig.GROUP_TYPE));