List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getDefaultUserId
public long getDefaultUserId() throws PortalException
From source file:com.liferay.wiki.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static WikiNode getFirstVisibleNode(PortletRequest portletRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); WikiNode node = null;/*from w ww .j av a 2 s. c om*/ int nodesCount = WikiNodeLocalServiceUtil.getNodesCount(themeDisplay.getScopeGroupId()); if (nodesCount == 0) { Layout layout = themeDisplay.getLayout(); ServiceContext serviceContext = ServiceContextFactory.getInstance(WikiNode.class.getName(), portletRequest); serviceContext.setAddGroupPermissions(true); if (layout.isPublicLayout() || layout.isTypeControlPanel()) { serviceContext.setAddGuestPermissions(true); } else { serviceContext.setAddGuestPermissions(false); } node = WikiNodeLocalServiceUtil.addDefaultNode(themeDisplay.getDefaultUserId(), serviceContext); } else { node = getFirstNode(portletRequest); if (node == null) { throw new PrincipalException(); } return node; } return node; }
From source file:com.liferay.wiki.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static WikiPage getFirstVisiblePage(long nodeId, PortletRequest portletRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); WikiWebComponentProvider wikiWebComponentProvider = WikiWebComponentProvider.getWikiWebComponentProvider(); WikiGroupServiceConfiguration wikiGroupServiceConfiguration = wikiWebComponentProvider .getWikiGroupServiceConfiguration(); WikiPage page = WikiPageLocalServiceUtil.fetchPage(nodeId, wikiGroupServiceConfiguration.frontPageName(), 0);//from w w w . ja va2 s . c o m if (page == null) { ServiceContext serviceContext = ServiceContextFactory.getInstance(WikiPage.class.getName(), portletRequest); serviceContext.setAddGuestPermissions(true); serviceContext.setAddGroupPermissions(true); boolean workflowEnabled = WorkflowThreadLocal.isEnabled(); try { WorkflowThreadLocal.setEnabled(false); page = WikiPageLocalServiceUtil.addPage(themeDisplay.getDefaultUserId(), nodeId, wikiGroupServiceConfiguration.frontPageName(), null, WikiPageConstants.NEW, true, serviceContext); } finally { WorkflowThreadLocal.setEnabled(workflowEnabled); } } return page; }