*/
public class UIPageActionListener {
public static class ChangeNodeActionListener extends EventListener<UIPortalApplication> {
public void execute(Event<UIPortalApplication> event) throws Exception {
PortalRequestContext pcontext = PortalRequestContext.getCurrentInstance();
UserPortal userPortal = pcontext.getUserPortalConfig().getUserPortal();
UIPortalApplication uiPortalApp = event.getSource();
UIPortal showedUIPortal = uiPortalApp.getCurrentSite();
UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder();
builder.withReadCheck();
PageNodeEvent<UIPortalApplication> pageNodeEvent = (PageNodeEvent<UIPortalApplication>) event;
String nodePath = pageNodeEvent.getTargetNodeUri();
UserNode targetNode = null;
SiteKey siteKey = pageNodeEvent.getSiteKey();
if (siteKey != null) {
if (pcontext.getRemoteUser() == null
&& (siteKey.getType().equals(SiteType.GROUP) || siteKey.getType().equals(SiteType.USER))) {
NavigationService service = uiPortalApp.getApplicationComponent(NavigationService.class);
NavigationContext navContext = service.loadNavigation(siteKey);
if (navContext != null) {
uiPortalApp.setLastRequestNavData(null);
pcontext.requestAuthenticationLogin();
return;
}
}
UserNavigation navigation = userPortal.getNavigation(siteKey);
if (navigation != null) {
targetNode = userPortal.resolvePath(navigation, builder.build(), nodePath);
if (targetNode == null) {
// If unauthenticated users have no permission on PORTAL node and URL is valid, they will be required to
// login
if (pcontext.getRemoteUser() == null && siteKey.getType().equals(SiteType.PORTAL)) {
targetNode = userPortal.resolvePath(navigation, null, nodePath);
if (targetNode != null) {
uiPortalApp.setLastRequestNavData(null);
pcontext.requestAuthenticationLogin();
return;
}
} else {
// If path to node is invalid, get the default node instead of.
targetNode = userPortal.getDefaultPath(navigation, builder.build());
}
}
}
}
if (targetNode == null) {
targetNode = userPortal.getDefaultPath(builder.build());
if (targetNode == null) {
if (showedUIPortal != null) {
UIPageBody uiPageBody = showedUIPortal.findFirstComponentOfType(UIPageBody.class);
uiPageBody.setUIComponent(null);
}