Author: ndkhoiits
Date: 2010-08-23 22:44:43 -0400 (Mon, 23 Aug 2010)
New Revision: 3896
Modified:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
Log:
GTNPORTAL-1389 Reload skin valuable in UIPortalApplication after have changed PortalConfig
skin
Modified:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2010-08-24
00:36:40 UTC (rev 3895)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2010-08-24
02:44:43 UTC (rev 3896)
@@ -292,6 +292,7 @@
DataStorage dataService = uiForm.getApplicationComponent(DataStorage.class);
UserPortalConfigService service =
uiForm.getApplicationComponent(UserPortalConfigService.class);
PortalRequestContext prContext = Util.getPortalRequestContext();
+ UIPortalApplication uiPortalApp =
(UIPortalApplication)prContext.getUIApplication();
UserPortalConfig userConfig =
service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser());
if (userConfig != null)
@@ -299,14 +300,14 @@
UIPortal uiPortal = uiForm.createUIComponent(UIPortal.class, null, null);
PortalDataMapper.toUIPortal(uiPortal, userConfig);
- UIPortalApplication uiPortalApp =
(UIPortalApplication)prContext.getUIApplication();
uiForm.invokeSetBindingBean(uiPortal);
//uiPortal.refreshNavigation(localeConfigService.getLocaleConfig(uiPortal.getLocale()).getLocale())
;
if (uiPortalApp.getModeState() == UIPortalApplication.NORMAL_MODE)
{
PortalConfig portalConfig =
(PortalConfig)PortalDataMapper.buildModelObject(uiPortal);
- UserPortalConfigService configService =
uiForm.getApplicationComponent(UserPortalConfigService.class);
dataService.save(portalConfig);
+ prContext.setAttribute(UserPortalConfig.class,
service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser()));
+ uiPortalApp.reloadSkinPortal(prContext);
}
else
{
@@ -320,7 +321,7 @@
{
UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
uiApp.addMessage(new
ApplicationMessage("UIPortalForm.msg.notExistAnymore", null));
- UIPortalApplication uiPortalApp =
(UIPortalApplication)prContext.getUIApplication();
+
UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
}
Modified:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-08-24
00:36:40 UTC (rev 3895)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-08-24
02:44:43 UTC (rev 3896)
@@ -140,29 +140,13 @@
if (userPortalConfig_ == null)
throw new Exception("Can't load user portal config");
+ // Get portal skin
+ this.reloadSkinPortal(context);
+
// dang.tung - set portal language by user preference -> browser ->
// default
// ------------------------------------------------------------------------------
LocaleConfigService localeConfigService =
getApplicationComponent(LocaleConfigService.class);
- OrganizationService orgService =
getApplicationComponent(OrganizationService.class);
-
- String user = context.getRemoteUser();
- String portalSkin = null;
-
- if (user != null)
- {
- UserProfile userProfile =
orgService.getUserProfileHandler().findUserProfileByName(user);
- if (userProfile != null)
- {
- portalSkin = userProfile.getUserInfoMap().get(Constants.USER_SKIN);
- }
- else
- {
- if (log.isWarnEnabled())
- log.warn("Could not load user profile for " + user + ".
Using default portal locale.");
- }
- }
-
Locale locale = context.getLocale();
if (locale == null)
{
@@ -187,18 +171,6 @@
this.all_UIPortals = new HashMap<UIPortalKey, UIPortal>(5);
addWorkingWorkspace();
-
- // use the skin from the user profile if available, otherwise use from the portal
config
- if (portalSkin != null && portalSkin.trim().length() > 0)
- {
- skin_ = portalSkin;
- }
- else
- {
- String userPortalConfigSkin = userPortalConfig_.getPortalConfig().getSkin();
- if (userPortalConfigSkin != null && userPortalConfigSkin.trim().length()
> 0)
- skin_ = userPortalConfigSkin;
- }
setOwner(context.getPortalOwner());
@@ -729,6 +701,47 @@
}
}
+ /**
+ * Get portal skin from {@link UserProfile} or from {@link UserPortalConfig}
+ *
+ * @param context PortalRequestContext
+ * @throws Exception
+ *
+ */
+ public void reloadSkinPortal(PortalRequestContext context) throws Exception
+ {
+ String user = context.getRemoteUser();
+ String portalSkin = null;
+ OrganizationService orgService =
getApplicationComponent(OrganizationService.class);
+
+ if (user != null)
+ {
+ UserProfile userProfile =
orgService.getUserProfileHandler().findUserProfileByName(user);
+ if (userProfile != null)
+ {
+ portalSkin = userProfile.getUserInfoMap().get(Constants.USER_SKIN);
+ }
+ else
+ {
+ if (log.isWarnEnabled())
+ log.warn("Could not load user profile for " + user + ".
Using default portal locale.");
+ }
+ }
+
+ // use the skin from the user profile if available, otherwise use from the portal
config
+ if (portalSkin != null && portalSkin.trim().length() > 0)
+ {
+ skin_ = portalSkin;
+ }
+ else
+ {
+ UserPortalConfig userPortalConfig =
(UserPortalConfig)context.getAttribute(UserPortalConfig.class);
+ String userPortalConfigSkin = userPortalConfig .getPortalConfig().getSkin();
+ if (userPortalConfigSkin != null && userPortalConfigSkin.trim().length()
> 0)
+ skin_ = userPortalConfigSkin;
+ }
+ }
+
public void setNavigations(List<PageNavigation> navs)
{
this.all_Navigations = navs;