1 5 package org.exoplatform.portal.faces.component; 6 7 import org.exoplatform.commons.exception.ExoPermissionException; 8 import org.exoplatform.container.SessionContainer; 9 import org.exoplatform.faces.core.component.UINode; 10 import org.exoplatform.portal.session.ExoPortal; 11 import org.exoplatform.portal.session.RequestInfo; 12 import org.exoplatform.services.portal.PortalACL; 13 import org.exoplatform.services.portal.PortalConfigService; 14 import org.exoplatform.services.portal.model.Node; 15 import org.exoplatform.services.portal.model.Page; 16 20 public class UIPageBrowser extends UINode { 21 static final public String UI_NAVIGATION_NODE_FORM = "UINavigationNodeForm" ; 22 static final public String UI_PAGE = "UIPage" ; 23 24 private PortalConfigService service_ ; 25 private String returnModule_ ; 26 27 public UIPageBrowser(PortalConfigService service) throws Exception { 28 setId("UIPageBrowser") ; 29 setRendererType("ChildrenRenderer") ; 30 service_ = service ; 31 RequestInfo rinfo = (RequestInfo)SessionContainer.getComponent(RequestInfo.class) ; 32 String owner = rinfo.getPortalOwner() ; 33 34 UIPageList uiPageList = (UIPageList) addChild(UIPageList.class) ; 35 uiPageList.queryDescriptions(owner, null, null) ; 36 addChild(UIPageModelForm.class).setRendered(false) ; 37 } 38 39 public PortalConfigService getPortalConfigService() { return service_ ; } 40 41 public void setReturnModule(String name) { returnModule_ = name ;} 42 43 public void goBack() { 44 UIPortal uiPortal = (UIPortal) getAncestorOfType(UIPortal.class); 45 if(UI_NAVIGATION_NODE_FORM.equals(returnModule_)) { 46 UIPageNodeForm uiForm = 47 (UIPageNodeForm)uiPortal.getPortalComponent(UIPageNodeForm.class); 48 uiPortal.setBodyComponent(uiForm) ; 49 } else { 50 uiPortal.setBodyComponent(uiPortal.getCurrentUIPage()) ; 51 } 52 } 53 54 public void setSelectNodeReferencePage(String refPage) throws Exception { 55 UIPortal uiPortal = (UIPortal) getAncestorOfType(UIPortal.class); 56 Page page = service_.getPage(refPage) ; 57 PortalACL acl = service_.getPortalACL() ; 58 if(!acl.hasViewPagePermission(page, uiPortal.getOwner())) { 59 throw new ExoPermissionException("selectPage", "onwer") ; 60 } 61 if(UI_NAVIGATION_NODE_FORM.equals(returnModule_)) { 62 UIPageNodeForm uiNavigationNodeForm = 63 (UIPageNodeForm)uiPortal.getPortalComponent(UIPageNodeForm.class); 64 uiNavigationNodeForm.returnReferencePage(refPage) ; 65 uiPortal.setBodyComponent(uiNavigationNodeForm) ; 66 } else { 67 Node selectNode = uiPortal.getSelectedNode() ; 68 selectNode.getPageReference(ExoPortal.XHTML_MIME_TYPE).setPageReference(refPage) ; 69 uiPortal.setSelectedNode(selectNode) ; 70 } 71 } 72 } | Popular Tags |