* Perform saving changes of the edition of SiteConfig into database
*
* @throws Exception if there is anything wrong in saving process
*/
private void save() 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();
String portalName = prContext.getPortalOwner();
PortalConfig portalConfig = (PortalConfig) PortalDataMapper.buildModelObject(editPortal);
DataStorage dataStorage = getApplicationComponent(DataStorage.class);
UserACL acl = getApplicationComponent(UserACL.class);
if (!isPortalExist(editPortal)) {
return;
}
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(portalName);
if (pConfig != null) {
editPortal.setModifiable(acl.hasEditPermission(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.getUserInfoMap().get(Constants.USER_LANGUAGE);
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());
// editPortal.refreshNavigation(localeConfig.getLocale());
// uiPortalApp.localizeNavigations();
}
uiPortalApp.setSkin(editPortal.getSkin());
}
prContext.refreshResourceBundle();
}