Author: julien_viet
Date: 2010-02-11 10:29:52 -0500 (Thu, 11 Feb 2010)
New Revision: 1640
Added:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
Log:
GTNPORTAL-627 : Create user site at request time when the user site does not exist
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java 2010-02-11
15:28:34 UTC (rev 1639)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java 2010-02-11
15:29:52 UTC (rev 1640)
@@ -21,15 +21,9 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.component.RequestLifeCycle;
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserEventListener;
-import java.util.ArrayList;
-
/**
* Created by The eXo Platform SAS May 29, 2007
*/
@@ -72,29 +66,7 @@
String userName = user.getUserName();
// Create the portal from the template
- portalConfigService.createUserPortalConfig(PortalConfig.USER_TYPE, userName,
"user");
-
- // Need to insert the corresponding user site if needed
- PortalConfig cfg = dataStorage.getPortalConfig(PortalConfig.USER_TYPE,
userName);
- if (cfg == null)
- {
- cfg = new PortalConfig(PortalConfig.USER_TYPE);
- cfg.setPortalLayout(new Container());
- cfg.setName(userName);
- dataStorage.create(cfg);
- }
-
- // Create a blank navigation if needed
- PageNavigation navigation =
dataStorage.getPageNavigation(PortalConfig.USER_TYPE, userName);
- if (navigation == null)
- {
- PageNavigation pageNav = new PageNavigation();
- pageNav.setOwnerType(PortalConfig.USER_TYPE);
- pageNav.setOwnerId(userName);
- pageNav.setPriority(5);
- pageNav.setNodes(new ArrayList<PageNode>());
- dataStorage.create(pageNav);
- }
+ portalConfigService.createUserSite(userName);
}
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
15:28:34 UTC (rev 1639)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-02-11
15:29:52 UTC (rev 1640)
@@ -199,19 +199,60 @@
}
/**
+ * Create a user site for the specified user. It will perform the following:
+ * <ul>
+ * <li>create the user 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>
+ * <li>if not navigation exists for the user site then it creates an empty
navigation</li>
+ * </ul>
+ *
+ * @param userName
+ * @throws Exception
+ */
+ public void createUserSite(String userName) throws Exception
+ {
+ // Create the portal from the template
+ createUserPortalConfig(PortalConfig.USER_TYPE, userName, "user");
+
+ // Need to insert the corresponding user site if needed
+ PortalConfig cfg = storage_.getPortalConfig(PortalConfig.USER_TYPE, userName);
+ if (cfg == null)
+ {
+ cfg = new PortalConfig(PortalConfig.USER_TYPE);
+ cfg.setPortalLayout(new Container());
+ cfg.setName(userName);
+ storage_.create(cfg);
+ }
+
+ // Create a blank navigation if needed
+ PageNavigation navigation = storage_.getPageNavigation(PortalConfig.USER_TYPE,
userName);
+ if (navigation == null)
+ {
+ PageNavigation pageNav = new PageNavigation();
+ pageNav.setOwnerType(PortalConfig.USER_TYPE);
+ pageNav.setOwnerId(userName);
+ pageNav.setPriority(5);
+ pageNav.setNodes(new ArrayList<PageNode>());
+ storage_.create(pageNav);
+ }
+ }
+
+ /**
* This method should create a the portal config, pages and navigation according to
the template name.
*
+ * @param siteType the site type
* @param siteName the Site name
* @param template the template to use
* @throws Exception any exception
*/
- public void createUserPortalConfig(String ownerType, String siteName, String template)
throws Exception
+ public void createUserPortalConfig(String siteType, String siteName, String template)
throws Exception
{
- String templatePath = newPortalConfigListener_.getTemplateConfig(ownerType,
template);
+ String templatePath = newPortalConfigListener_.getTemplateConfig(siteType,
template);
NewPortalConfig portalConfig = new NewPortalConfig(templatePath);
portalConfig.setTemplateName(template);
- portalConfig.setOwnerType(ownerType);
+ portalConfig.setOwnerType(siteType);
if (!portalConfig.getOwnerType().equals(PortalConfig.USER_TYPE))
{
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-02-11 15:28:34 UTC (rev
1639)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-02-11 15:29:52 UTC (rev
1640)
@@ -86,10 +86,12 @@
<filter-class>org.exoplatform.web.login.ClusteredSSOFilter</filter-class>
</filter>
+<!--
<filter>
<filter-name>UserGroupFilter</filter-name>
<filter-class>org.exoplatform.portal.filter.UserGroupFilter</filter-class>
</filter>
+-->
<filter-mapping>
<filter-name>ClusteredSSOFilter</filter-name>
@@ -132,11 +134,6 @@
</filter-mapping>
<filter-mapping>
- <filter-name>UserGroupFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter-mapping>
<filter-name>CacheUserProfileFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-02-11
15:28:34 UTC (rev 1639)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-02-11
15:29:52 UTC (rev 1640)
@@ -32,6 +32,7 @@
<state-manager>org.exoplatform.portal.application.PortalStateManager</state-manager>
<application-lifecycle-listeners>
+
<listener>org.exoplatform.portal.application.UserSiteLifeCycle</listener>
<listener>org.exoplatform.portal.application.PortalStatisticLifecycle</listener>
<listener>org.exoplatform.portal.application.PortalApplicationLifecycle</listener>
<listener>org.exoplatform.webui.application.MonitorApplicationLifecycle</listener>
Added:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java 2010-02-11
15:29:52 UTC (rev 1640)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.application;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.ApplicationLifecycle;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class UserSiteLifeCycle implements
ApplicationLifecycle<PortalRequestContext>
+{
+
+ public void onInit(Application app) throws Exception
+ {
+
+ }
+
+ public void onStartRequest(Application app, PortalRequestContext context) throws
Exception
+ {
+ String userName = context.getRemoteUser();
+
+ //
+ if (userName != null)
+ {
+ DataStorage storage =
(DataStorage)PortalContainer.getComponent(DataStorage.class);
+
+ //
+ PortalConfig portalConfig = storage.getPortalConfig("user",
userName);
+
+ //
+ if (portalConfig == null)
+ {
+ UserPortalConfigService configService =
(UserPortalConfigService)PortalContainer.getComponent(UserPortalConfigService.class);
+ configService.createUserSite(userName);
+ }
+ }
+ }
+
+ public void onEndRequest(Application app, PortalRequestContext context) throws
Exception
+ {
+
+ }
+
+ public void onDestroy(Application app) throws Exception
+ {
+
+ }
+}