List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPermissionChecker
@JSON(include = false)
public PermissionChecker getPermissionChecker()
From source file:com.liferay.layout.admin.web.internal.portlet.action.ResetCustomizationViewMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), themeDisplay.getLayout(), ActionKeys.CUSTOMIZE)) {/*from w w w . j av a 2s.co m*/ throw new PrincipalException(); } LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); if ((layoutTypePortlet != null) && layoutTypePortlet.isCustomizable() && layoutTypePortlet.isCustomizedView()) { layoutTypePortlet.resetUserPreferences(); } MultiSessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + "requestProcessed"); Layout layout = themeDisplay.getLayout(); actionResponse.sendRedirect(layout.getRegularURL(_portal.getHttpServletRequest(actionRequest))); }
From source file:com.liferay.layout.admin.web.internal.portlet.configuration.icon.EditPrivatePagesPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); LiferayPortletRequest liferayPortletRequest = _portal.getLiferayPortletRequest(portletRequest); LayoutsAdminDisplayContext layoutsAdminDisplayContext = new LayoutsAdminDisplayContext( liferayPortletRequest, null); if (layoutsAdminDisplayContext.isPageTemplates() || layoutsAdminDisplayContext.isPublicPages()) { return false; }/* w w w . j a v a 2s. c o m*/ try { return GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), layoutsAdminDisplayContext.getSelGroupId(), ActionKeys.MANAGE_LAYOUTS); } catch (Exception e) { } return false; }
From source file:com.liferay.layout.admin.web.internal.portlet.configuration.icon.EditPublicPagesPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); LiferayPortletRequest liferayPortletRequest = _portal.getLiferayPortletRequest(portletRequest); LayoutsAdminDisplayContext layoutsAdminDisplayContext = new LayoutsAdminDisplayContext( liferayPortletRequest, null); if (layoutsAdminDisplayContext.isPageTemplates() || layoutsAdminDisplayContext.isPrivatePages() || !layoutsAdminDisplayContext.isShowPublicPages()) { return false; }/*from www.j a v a 2 s . c om*/ try { return GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), layoutsAdminDisplayContext.getSelGroupId(), ActionKeys.MANAGE_LAYOUTS); } catch (Exception e) { } return false; }
From source file:com.liferay.layout.admin.web.internal.product.navigation.control.menu.InformationMessagesProductNavigationControlMenuEntry.java
License:Open Source License
protected boolean isLinkedLayout(ThemeDisplay themeDisplay) throws PortalException { Layout layout = themeDisplay.getLayout(); Group group = layout.getGroup(); if (!SitesUtil.isLayoutUpdateable(layout) || (layout.isLayoutPrototypeLinkActive() && !group.hasStagingGroup())) { if (!LayoutPermissionUtil.containsWithoutViewableGroup(themeDisplay.getPermissionChecker(), layout, false, ActionKeys.UPDATE)) { return false; }//from w ww . ja v a 2s. c o m return true; } return false; }
From source file:com.liferay.layout.internal.util.LayoutsTreeImpl.java
License:Open Source License
private boolean _isDeleteable(Layout layout, ThemeDisplay themeDisplay, LayoutSetBranch layoutSetBranch) throws PortalException { if (!LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.DELETE)) { return false; }/*from w w w . ja v a 2 s . c o m*/ Group group = layout.getGroup(); if (group.isGuest() && !layout.isPrivateLayout() && layout.isRootLayout() && (_layoutLocalService .getLayoutsCount(group, false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) == 1)) { return false; } if (layoutSetBranch != null) { List<LayoutRevision> layoutRevisions = _layoutRevisionLocalService .getLayoutRevisions(layoutSetBranch.getLayoutSetBranchId(), layout.getPlid()); if (layoutRevisions.size() == 1) { LayoutRevision layoutRevision = layoutRevisions.get(0); if (layoutRevision.isIncomplete()) { return false; } } } return true; }
From source file:com.liferay.layout.internal.util.LayoutsTreeImpl.java
License:Open Source License
private JSONObject _toJSONObject(HttpServletRequest request, long groupId, LayoutTreeNodes layoutTreeNodes, LayoutSetBranch layoutSetBranch) throws Exception { if (_log.isDebugEnabled()) { StringBundler sb = new StringBundler(5); sb.append("_toJSON(groupId="); sb.append(groupId);// w w w. ja v a 2 s . co m sb.append(", layoutTreeNodes="); sb.append(layoutTreeNodes); sb.append(StringPool.CLOSE_PARENTHESIS); _log.debug(sb.toString()); } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); boolean hasManageLayoutsPermission = GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), groupId, ActionKeys.MANAGE_LAYOUTS); boolean mobile = BrowserSnifferUtil.isMobile(request); for (LayoutTreeNode layoutTreeNode : layoutTreeNodes) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject childrenJSONObject = _toJSONObject(request, groupId, layoutTreeNode.getChildLayoutTreeNodes(), layoutSetBranch); jsonObject.put("children", childrenJSONObject); Layout layout = layoutTreeNode.getLayout(); jsonObject.put("contentDisplayPage", layout.isContentDisplayPage()); jsonObject.put("deleteable", _isDeleteable(layout, themeDisplay, layoutSetBranch)); jsonObject.put("friendlyURL", layout.getFriendlyURL()); if (layout instanceof VirtualLayout) { VirtualLayout virtualLayout = (VirtualLayout) layout; jsonObject.put("groupId", virtualLayout.getSourceGroupId()); } else { jsonObject.put("groupId", layout.getGroupId()); } jsonObject.put("hasChildren", layout.hasChildren()); jsonObject.put("layoutId", layout.getLayoutId()); jsonObject.put("name", layout.getName(themeDisplay.getLocale())); jsonObject.put("parentable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.ADD_LAYOUT)); jsonObject.put("parentLayoutId", layout.getParentLayoutId()); jsonObject.put("plid", layout.getPlid()); jsonObject.put("priority", layout.getPriority()); jsonObject.put("privateLayout", layout.isPrivateLayout()); jsonObject.put("regularURL", layout.getRegularURL(request)); jsonObject.put("sortable", hasManageLayoutsPermission && !mobile && SitesUtil.isLayoutSortable(layout)); jsonObject.put("type", layout.getType()); jsonObject.put("updateable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.UPDATE)); jsonObject.put("uuid", layout.getUuid()); LayoutRevision layoutRevision = LayoutStagingUtil.getLayoutRevision(layout); if (layoutRevision != null) { long layoutSetBranchId = layoutRevision.getLayoutSetBranchId(); if (_staging.isIncomplete(layout, layoutSetBranchId)) { jsonObject.put("incomplete", true); } LayoutSetBranch boundLayoutSetBranch = _layoutSetBranchLocalService .getLayoutSetBranch(layoutSetBranchId); LayoutBranch layoutBranch = layoutRevision.getLayoutBranch(); if (!layoutBranch.isMaster()) { jsonObject.put("layoutBranchId", layoutBranch.getLayoutBranchId()); jsonObject.put("layoutBranchName", layoutBranch.getName()); } if (layoutRevision.isHead()) { jsonObject.put("layoutRevisionHead", true); } jsonObject.put("layoutRevisionId", layoutRevision.getLayoutRevisionId()); jsonObject.put("layoutSetBranchId", layoutSetBranchId); jsonObject.put("layoutSetBranchName", boundLayoutSetBranch.getName()); } jsonArray.put(jsonObject); } JSONObject responseJSONObject = JSONFactoryUtil.createJSONObject(); responseJSONObject.put("layouts", jsonArray); responseJSONObject.put("total", layoutTreeNodes.getTotal()); return responseJSONObject; }
From source file:com.liferay.layout.prototype.web.internal.display.context.LayoutPrototypeDisplayContext.java
License:Open Source License
public boolean isShowAddButton() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (PortalPermissionUtil.contains(themeDisplay.getPermissionChecker(), ActionKeys.ADD_LAYOUT_PROTOTYPE)) { return true; }//from w w w . jav a 2 s. co m return false; }
From source file:com.liferay.layout.set.prototype.web.internal.display.context.LayoutSetPrototypeDisplayContext.java
License:Open Source License
public boolean isShowAddButton() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (PortalPermissionUtil.contains(themeDisplay.getPermissionChecker(), ActionKeys.ADD_LAYOUT_SET_PROTOTYPE)) { return true; }/* w ww. j a v a2 s .c om*/ return false; }
From source file:com.liferay.message.boards.web.internal.display.context.DefaultMBListDisplayContext.java
License:Open Source License
@Override public void populateResultsAndTotal(SearchContainer searchContainer) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (isShowSearch()) { long searchCategoryId = ParamUtil.getLong(_request, "searchCategoryId"); long[] categoryIdsArray = null; List categoryIds = new ArrayList(); categoryIds.add(Long.valueOf(searchCategoryId)); MBCategoryServiceUtil.getSubcategoryIds(categoryIds, themeDisplay.getScopeGroupId(), searchCategoryId); categoryIdsArray = StringUtil.split(StringUtil.merge(categoryIds), 0L); Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class); SearchContext searchContext = SearchContextFactory.getInstance(_request); searchContext.setAttribute("paginationType", "more"); searchContext.setCategoryIds(categoryIdsArray); searchContext.setEnd(searchContainer.getEnd()); searchContext.setIncludeAttachments(true); String keywords = ParamUtil.getString(_request, "keywords"); searchContext.setKeywords(keywords); searchContext.setStart(searchContainer.getStart()); Hits hits = indexer.search(searchContext); searchContainer.setResults(SearchResultUtil.getSearchResults(hits, _request.getLocale())); searchContainer.setSearch(true); searchContainer.setTotal(hits.getLength()); } else if (isShowRecentPosts()) { searchContainer.setEmptyResultsMessage("there-are-no-recent-posts"); long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId"); Calendar calendar = Calendar.getInstance(); MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings .getInstance(themeDisplay.getSiteGroupId()); int offset = GetterUtil.getInteger(mbGroupServiceSettings.getRecentPostsDateOffset()); calendar.add(Calendar.DATE, -offset); searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(), groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED)); searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(), groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED, searchContainer.getStart(), searchContainer.getEnd())); } else if (isShowMyPosts()) { long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId"); if (themeDisplay.isSignedIn()) { groupThreadsUserId = themeDisplay.getUserId(); }//from w w w. j a v a 2 s . co m int status = WorkflowConstants.STATUS_ANY; searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(), groupThreadsUserId, status)); searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(), groupThreadsUserId, status, searchContainer.getStart(), searchContainer.getEnd())); searchContainer.setEmptyResultsMessage("you-do-not-have-any-posts"); } else { int status = WorkflowConstants.STATUS_APPROVED; PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())) { status = WorkflowConstants.STATUS_ANY; } searchContainer.setTotal(MBCategoryLocalServiceUtil .getCategoriesAndThreadsCount(themeDisplay.getScopeGroupId(), _categoryId, status)); searchContainer.setResults(MBCategoryServiceUtil.getCategoriesAndThreads(themeDisplay.getScopeGroupId(), _categoryId, status, searchContainer.getStart(), searchContainer.getEnd())); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static MBCategory getCategory(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName"); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (mvcRenderCommandName.equals("/message_boards/view_banned_users") && !MBPermission.contains(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.BAN_USER)) { throw new PrincipalException.MustHavePermission(permissionChecker, ActionKeys.BAN_USER); }/*from w w w. j a v a 2 s . com*/ MBBanLocalServiceUtil.checkBan(themeDisplay.getScopeGroupId(), themeDisplay.getUserId()); long categoryId = ParamUtil.getLong(request, "mbCategoryId"); MBCategory category = null; if (categoryId > 0) { category = MBCategoryServiceUtil.getCategory(categoryId); } else { MBPermission.check(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.VIEW); } return category; }