List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId
public long getScopeGroupId()
From source file:com.liferay.asset.tags.admin.web.internal.display.context.AssetTagsDisplayContext.java
License:Open Source License
public SearchContainer getTagsSearchContainer() throws PortalException { if (_tagsSearchContainer != null) { return _tagsSearchContainer; }//ww w . j ava2 s .c o m SearchContainer tagsSearchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(), null, "there-are-no-tags"); String keywords = getKeywords(); if (Validator.isNull(keywords)) { if (isShowAddButton()) { tagsSearchContainer.setEmptyResultsMessage("there-are-no-tags.-you-can-add-a-tag-by-clicking-the-" + "plus-button-on-the-bottom-right-corner"); tagsSearchContainer .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } } else { tagsSearchContainer.setSearch(true); } tagsSearchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse)); ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (Validator.isNotNull(keywords)) { Sort sort = null; String orderByCol = getOrderByCol(); if (orderByCol.equals("name")) { sort = SortFactoryUtil.getSort(AssetTag.class, Sort.STRING_TYPE, Field.NAME, getOrderByType()); } else if (orderByCol.equals("usages")) { sort = SortFactoryUtil.getSort(AssetTag.class, Sort.INT_TYPE, "assetCount_Number", getOrderByType()); } BaseModelSearchResult<AssetTag> baseModelSearchResult = AssetTagLocalServiceUtil.searchTags( new long[] { themeDisplay.getScopeGroupId() }, keywords, tagsSearchContainer.getStart(), tagsSearchContainer.getEnd(), sort); tagsSearchContainer.setResults(baseModelSearchResult.getBaseModels()); tagsSearchContainer.setTotal(baseModelSearchResult.getLength()); } else { String orderByCol = getOrderByCol(); tagsSearchContainer.setOrderByCol(orderByCol); OrderByComparator<AssetTag> orderByComparator = null; boolean orderByAsc = false; String orderByType = getOrderByType(); if (orderByType.equals("asc")) { orderByAsc = true; } if (orderByCol.equals("name")) { orderByComparator = new AssetTagNameComparator(orderByAsc); } else if (orderByCol.equals("usages")) { orderByComparator = new AssetTagAssetCountComparator(orderByAsc); } tagsSearchContainer.setOrderByComparator(orderByComparator); tagsSearchContainer.setOrderByType(orderByType); long scopeGroupId = themeDisplay.getScopeGroupId(); int tagsCount = AssetTagServiceUtil.getTagsCount(scopeGroupId, keywords); tagsSearchContainer.setTotal(tagsCount); List<AssetTag> tags = AssetTagServiceUtil.getTags(scopeGroupId, StringPool.BLANK, tagsSearchContainer.getStart(), tagsSearchContainer.getEnd(), tagsSearchContainer.getOrderByComparator()); tagsSearchContainer.setResults(tags); } _tagsSearchContainer = tagsSearchContainer; return _tagsSearchContainer; }
From source file:com.liferay.asset.tags.selector.web.internal.display.context.AssetTagsSelectorDisplayContext.java
License:Open Source License
public long[] getGroupIds() { if (ArrayUtil.isNotEmpty(_groupIds)) { return _groupIds; }/*from ww w .ja v a2 s.co m*/ ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); _groupIds = StringUtil.split(ParamUtil.getString(_request, "groupIds"), 0L); if (ArrayUtil.isEmpty(_groupIds)) { _groupIds = new long[] { themeDisplay.getScopeGroupId() }; } return _groupIds; }
From source file:com.liferay.asset.tags.selector.web.internal.display.context.AssetTagsSelectorDisplayContext.java
License:Open Source License
public SearchContainer getTagsSearchContainer() { if (_tagsSearchContainer != null) { return _tagsSearchContainer; }/*w ww. j a va 2 s. c om*/ ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); SearchContainer tagsSearchContainer = new SearchContainer(_renderRequest, getPortletURL(), null, "there-are-no-tags"); String keywords = getKeywords(); if (Validator.isNotNull(keywords)) { tagsSearchContainer.setSearch(true); } String orderByCol = getOrderByCol(); tagsSearchContainer.setOrderByCol(orderByCol); boolean orderByAsc = false; String orderByType = getOrderByType(); if (orderByType.equals("asc")) { orderByAsc = true; } tagsSearchContainer.setOrderByComparator(new AssetTagNameComparator(orderByAsc)); tagsSearchContainer.setOrderByType(orderByType); tagsSearchContainer.setRowChecker(new EntriesChecker(_renderRequest, _renderResponse)); int tagsCount = AssetTagServiceUtil.getTagsCount(themeDisplay.getScopeGroupId(), keywords); tagsSearchContainer.setTotal(tagsCount); List<AssetTag> tags = AssetTagServiceUtil.getTags(getGroupIds(), keywords, tagsSearchContainer.getStart(), tagsSearchContainer.getEnd(), tagsSearchContainer.getOrderByComparator()); tagsSearchContainer.setResults(tags); _tagsSearchContainer = tagsSearchContainer; return _tagsSearchContainer; }
From source file:com.liferay.blogs.web.internal.display.context.BlogsPortletInstanceSettingsHelper.java
License:Open Source License
public long getDisplayStyleGroupId() { if (_displayStyleGroupId != 0) { return _displayStyleGroupId; }/* w w w. j a va2 s. co m*/ _displayStyleGroupId = _blogsPortletInstanceConfiguration.displayStyleGroupId(); if (_displayStyleGroupId <= 0) { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); _displayStyleGroupId = themeDisplay.getScopeGroupId(); } return _displayStyleGroupId; }
From source file:com.liferay.blogs.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static void getEntry(PortletRequest portletRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); long entryId = ParamUtil.getLong(portletRequest, "entryId"); String urlTitle = ParamUtil.getString(portletRequest, "urlTitle"); BlogsEntry entry = null;/* ww w . ja va2 s . c om*/ if (entryId > 0) { entry = BlogsEntryServiceUtil.getEntry(entryId); } else if (Validator.isNotNull(urlTitle) && SessionErrors.isEmpty(portletRequest)) { try { entry = BlogsEntryServiceUtil.getEntry(themeDisplay.getScopeGroupId(), urlTitle); } catch (NoSuchEntryException nsee) { if (urlTitle.indexOf(CharPool.UNDERLINE) != -1) { // Check another URL title for backwards compatibility. See // LEP-5733. urlTitle = StringUtil.replace(urlTitle, CharPool.UNDERLINE, CharPool.DASH); entry = BlogsEntryServiceUtil.getEntry(themeDisplay.getScopeGroupId(), urlTitle); } else { throw nsee; } } } if ((entry != null) && entry.isInTrash()) { throw new NoSuchEntryException("{entryId=" + entryId + "}"); } HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); request.setAttribute(WebKeys.BLOGS_ENTRY, entry); }
From source file:com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand.java
License:Open Source License
protected void subscribe(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); _blogsEntryService.subscribe(themeDisplay.getScopeGroupId()); }
From source file:com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand.java
License:Open Source License
protected void unsubscribe(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); _blogsEntryService.unsubscribe(themeDisplay.getScopeGroupId()); }
From source file:com.liferay.blogs.web.internal.portlet.action.EditImageMVCActionCommand.java
License:Open Source License
protected void deleteImages(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] deleteFileEntryIds = null; long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId"); if (fileEntryId > 0) { deleteFileEntryIds = new long[] { fileEntryId }; } else {//from w ww .j a v a 2 s . co m deleteFileEntryIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteFileEntryIds"), 0L); } Folder folder = _blogsEntryLocalService.addAttachmentsFolder(themeDisplay.getUserId(), themeDisplay.getScopeGroupId()); for (long deleteFileEntryId : deleteFileEntryIds) { FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(deleteFileEntryId); if (fileEntry.getFolderId() != folder.getFolderId()) { continue; } if ((fileEntry.getUserId() == themeDisplay.getUserId()) || BlogsPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.UPDATE)) { PortletFileRepositoryUtil.deletePortletFileEntry(deleteFileEntryId); } } }
From source file:com.liferay.blogs.web.internal.portlet.action.RSSAction.java
License:Open Source License
@Override protected byte[] getRSS(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); long plid = ParamUtil.getLong(request, "p_l_id"); if (plid == LayoutConstants.DEFAULT_PLID) { plid = themeDisplay.getPlid();// w w w . j av a2 s .co m } long companyId = ParamUtil.getLong(request, "companyId"); long groupId = ParamUtil.getLong(request, "groupId"); long organizationId = ParamUtil.getLong(request, "organizationId"); int status = WorkflowConstants.STATUS_APPROVED; int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA); String type = ParamUtil.getString(request, "type", RSSUtil.FORMAT_DEFAULT); double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT); String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT); String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/blogs/find_entry?"; String entryURL = feedURL; String rss = StringPool.BLANK; if (companyId > 0) { feedURL = StringPool.BLANK; rss = _blogsEntryService.getCompanyEntriesRSS(companyId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (groupId > 0) { feedURL += "p_l_id=" + plid; entryURL = feedURL; rss = _blogsEntryService.getGroupEntriesRSS(groupId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (organizationId > 0) { feedURL = StringPool.BLANK; rss = _blogsEntryService.getOrganizationEntriesRSS(organizationId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (layout != null) { groupId = themeDisplay.getScopeGroupId(); feedURL = themeDisplay.getPathMain() + "/blogs/rss"; entryURL = feedURL; rss = _blogsEntryService.getGroupEntriesRSS(groupId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } return rss.getBytes(StringPool.UTF8); }
From source file:com.liferay.blogs.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java
License:Open Source License
@Override public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) { String url = StringPool.BLANK; ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); try {/*from w w w .j a v a 2 s . c om*/ url = PermissionsURLTag.doTag(StringPool.BLANK, "com.liferay.blogs", themeDisplay.getScopeGroupName(), null, String.valueOf(themeDisplay.getScopeGroupId()), LiferayWindowState.POP_UP.toString(), null, themeDisplay.getRequest()); } catch (Exception e) { } return url; }