*/
public void saveSite() throws Exception {
PortalRequestContext prContext = Util.getPortalRequestContext();
UIPortalApplication uiPortalApp = (UIPortalApplication) prContext.getUIApplication();
UIWorkingWorkspace uiWorkingWS = uiPortalApp.findFirstComponentOfType(UIWorkingWorkspace.class);
UIEditInlineWorkspace uiEditWS = uiWorkingWS.getChild(UIEditInlineWorkspace.class);
UIPortal editPortal = (UIPortal) uiEditWS.getUIComponent();
UIPortal uiPortal = Util.getUIPortal();
String remoteUser = prContext.getRemoteUser();
PortalConfig portalConfig = (PortalConfig) PortalDataMapper.buildModelObject(editPortal);
DataStorage dataStorage = getApplicationComponent(DataStorage.class);
UserACL acl = getApplicationComponent(UserACL.class);
setEditted(false);
// Reset tab pane state
UITabPane tabPane = getChild(UITabPane.class);
tabPane.setSelectedTab(1);
uiPortalApp.setSessionOpen(PortalProperties.SESSION_ALWAYS.equals(uiPortal.getSessionAlive()));
uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
prContext.ignoreAJAXUpdateOnPortlets(true);
if (isPortalExist(editPortal)) {
SkinService skinService = getApplicationComponent(SkinService.class);
skinService.invalidatePortalSkinCache(editPortal.getName(), editPortal.getSkin());
try {
dataStorage.save(portalConfig);
} catch (StaleModelException ex) {
// Temporary solution for concurrency-related issue. The StaleModelException should be
// caught in the ApplicationLifecycle
rebuildUIPortal(uiPortalApp, editPortal, dataStorage);
}
prContext.getUserPortalConfig().setPortalConfig(portalConfig);
PortalConfig pConfig = dataStorage.getPortalConfig(uiPortal.getSiteKey().getTypeName(), uiPortal.getSiteKey()
.getName());
if (pConfig != null) {
editPortal.setModifiable(acl.hasEditPermission(pConfig));
prContext.getUserPortalConfig().setPortalConfig(pConfig);
} else {
editPortal.setModifiable(false);
}
LocaleConfigService localeConfigService = uiPortalApp.getApplicationComponent(LocaleConfigService.class);
LocaleConfig localeConfig = localeConfigService.getLocaleConfig(portalConfig.getLocale());
if (localeConfig == null) {
localeConfig = localeConfigService.getDefaultLocaleConfig();
}
// TODO dang.tung - change layout when portal get language from UIPortal
// (user and browser not support)
// ----------------------------------------------------------------------------------------------------
String portalAppLanguage = prContext.getLocale().getLanguage();
OrganizationService orgService = getApplicationComponent(OrganizationService.class);
UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(remoteUser);
String userLanguage = userProfile != null ? userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE) : null;
String browserLanguage = prContext.getRequest().getLocale().getLanguage();
// in case: edit current portal, set skin and language for uiPortalApp
if (uiPortal == null) {
if (!portalAppLanguage.equals(userLanguage) && !portalAppLanguage.equals(browserLanguage)) {
prContext.setLocale(localeConfig.getLocale());
}
uiPortalApp.setSkin(editPortal.getSkin());
}
prContext.refreshResourceBundle();
UISiteBody siteBody = uiWorkingWS.findFirstComponentOfType(UISiteBody.class);
uiPortal = (UIPortal) siteBody.getUIComponent();
if (uiPortal == null) {
siteBody.setUIComponent(editPortal);
}
uiEditWS.setRendered(false);
uiPortal = (UIPortal) siteBody.getUIComponent();
// Update the cache of UIPortal from UIPortalApplication
uiPortalApp.refreshCachedUI();