public void execute(Event<UINavigationManagement> event) throws Exception
{
PortalRequestContext prContext = Util.getPortalRequestContext();
UINavigationManagement uiManagement = event.getSource();
UINavigationNodeSelector uiNodeSelector = uiManagement.getChild(UINavigationNodeSelector.class);
DataStorage dataService = uiManagement.getApplicationComponent(DataStorage.class);
UserPortalConfigService portalConfigService = uiManagement.getApplicationComponent(UserPortalConfigService.class);
PageNavigation navigation = uiNodeSelector.getEdittedNavigation();
String editedOwnerType = navigation.getOwnerType();
String editedOwnerId = navigation.getOwnerId();
// Check existed
PageNavigation persistNavigation = dataService.getPageNavigation(editedOwnerType, editedOwnerId);
if (persistNavigation == null)
{
UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
uiApp.addMessage(new ApplicationMessage("UINavigationManagement.msg.NavigationNotExistAnymore", null));
UIPopupWindow uiPopup = uiManagement.getParent();
uiPopup.setShow(false);
UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
prContext.setFullRender(true);
return;
}
if(PortalConfig.PORTAL_TYPE.equals(navigation.getOwnerType()))
{
UserPortalConfig portalConfig = portalConfigService.getUserPortalConfig(navigation.getOwnerId(), prContext.getRemoteUser());
if(portalConfig != null)
{
dataService.save(navigation);
}
else
{
UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
uiApp.addMessage(new ApplicationMessage("UIPortalForm.msg.notExistAnymore", null));
UIPopupWindow uiPopup = uiManagement.getParent();
uiPopup.setShow(false);
UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
prContext.setFullRender(true);
return;
}
}
else
{
dataService.save(navigation);
}
// Reload navigation here as some navigation could exist in the back end such as system navigations
// that would not be in the current edited UI navigation
navigation = dataService.getPageNavigation(navigation.getOwnerType(), navigation.getOwnerId());
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
setNavigation(uiPortalApp.getNavigations(), navigation);
// Need to relocalize as it was loaded from storage