List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getSiteGroupId
public long getSiteGroupId()
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(); }/* w w w. ja v a 2 s . c o 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.MBAdminConfigurationAction.java
License:Open Source License
protected void updateThreadPriorities(ActionRequest actionRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); for (Locale locale : LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId())) { String languageId = LocaleUtil.toLanguageId(locale); List<String> priorities = new ArrayList<>(); for (int j = 0; j < 10; j++) { String name = ParamUtil.getString(actionRequest, "priorityName" + j + "_" + languageId); String image = ParamUtil.getString(actionRequest, "priorityImage" + j + "_" + languageId); double value = ParamUtil.getDouble(actionRequest, "priorityValue" + j + "_" + languageId); if (Validator.isNotNull(name) || Validator.isNotNull(image) || (value != 0.0)) { priorities.add(name + StringPool.PIPE + image + StringPool.PIPE + value); }//from w w w .j av a2 s . c om } String preferenceName = LocalizationUtil.getLocalizedName("priorities", languageId); setPreference(actionRequest, preferenceName, priorities.toArray(new String[priorities.size()])); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.MBAdminConfigurationAction.java
License:Open Source License
protected void updateUserRanks(ActionRequest actionRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); for (Locale locale : LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId())) { String languageId = LocaleUtil.toLanguageId(locale); String[] ranks = StringUtil.splitLines(ParamUtil.getString(actionRequest, "ranks_" + languageId)); Map<String, String> map = new TreeMap<>(new NaturalOrderStringComparator()); for (String rank : ranks) { if (!isValidUserRank(rank)) { SessionErrors.add(actionRequest, "userRank"); return; }/* w w w .j av a 2 s . c o m*/ String[] kvp = StringUtil.split(rank, CharPool.EQUAL); String kvpName = kvp[0]; String kvpValue = kvp[1]; map.put(kvpValue, kvpName); } ranks = new String[map.size()]; int count = 0; for (Map.Entry<String, String> entry : map.entrySet()) { String kvpValue = entry.getKey(); String kvpName = entry.getValue(); ranks[count++] = kvpName + StringPool.EQUAL + kvpValue; } String preferenceName = LocalizationUtil.getLocalizedName("ranks", languageId); setPreference(actionRequest, preferenceName, ranks); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.RSSAction.java
License:Open Source License
@Override protected boolean isRSSFeedsEnabled(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings .getInstance(themeDisplay.getSiteGroupId()); return mbGroupServiceSettings.isEnableRSS(); }
From source file:com.liferay.polls.web.internal.portlet.action.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 ww w . j a v a 2 s. c o m*/ url = PermissionsURLTag.doTag(StringPool.BLANK, "com.liferay.polls", themeDisplay.getScopeGroupName(), null, String.valueOf(themeDisplay.getSiteGroupId()), LiferayWindowState.POP_UP.toString(), null, themeDisplay.getRequest()); } catch (Exception e) { } return url; }
From source file:com.liferay.portlet.configuration.css.web.internal.portlet.PortletConfigurationCSSPortlet.java
License:Open Source License
public void getLookAndFeel(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); try {/* ww w .j a va 2 s .c o m*/ Layout layout = themeDisplay.getLayout(); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); String portletId = ParamUtil.getString(resourceRequest, "portletId"); if (!PortletPermissionUtil.contains(permissionChecker, layout, portletId, ActionKeys.CONFIGURATION)) { return; } PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(layout, portletId); JSONObject portletSetupJSONObject = PortletSetupUtil.cssToJSONObject(portletSetup); JSONObject defaultPortletTitlesJSONObject = JSONFactoryUtil.createJSONObject(); for (Locale locale : LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId())) { String rootPortletId = PortletConstants.getRootPortletId(portletId); String languageId = LocaleUtil.toLanguageId(locale); defaultPortletTitlesJSONObject.put(languageId, _portal.getPortletTitle(rootPortletId, languageId)); } portletSetupJSONObject.put("defaultPortletTitles", defaultPortletTitlesJSONObject); writeJSON(resourceRequest, resourceResponse, portletSetupJSONObject.toString()); } catch (Exception e) { throw new PortletException(e); } }
From source file:com.liferay.portlet.configuration.css.web.internal.portlet.PortletConfigurationCSSPortlet.java
License:Open Source License
public void updateLookAndFeel(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); String portletId = ParamUtil.getString(actionRequest, "portletId"); if (!PortletPermissionUtil.contains(permissionChecker, layout, portletId, ActionKeys.CONFIGURATION)) { return;/*from www . j ava 2 s. c o m*/ } PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(layout, portletId); String css = ParamUtil.getString(actionRequest, "css"); if (_log.isDebugEnabled()) { _log.debug("Updating css " + css); } JSONObject jsonObject = JSONFactoryUtil.createJSONObject(css); JSONObject portletDataJSONObject = jsonObject.getJSONObject("portletData"); jsonObject.remove("portletData"); css = jsonObject.toString(); String linkToLayoutUuid = GetterUtil.getString(portletDataJSONObject.getString("portletLinksTarget")); String portletDecoratorId = portletDataJSONObject.getString("portletDecoratorId"); JSONObject titlesJSONObject = portletDataJSONObject.getJSONObject("titles"); boolean useCustomTitle = portletDataJSONObject.getBoolean("useCustomTitle"); Set<Locale> locales = LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId()); for (Locale locale : locales) { String languageId = LocaleUtil.toLanguageId(locale); String title = null; if (titlesJSONObject.has(languageId)) { title = GetterUtil.getString(titlesJSONObject.getString(languageId)); } String rootPortletId = PortletConstants.getRootPortletId(portletId); String defaultPortletTitle = _portal.getPortletTitle(rootPortletId, languageId); if ((title != null) && !Objects.equals(defaultPortletTitle, title)) { portletSetup.setValue("portletSetupTitle_" + languageId, title); } else { portletSetup.reset("portletSetupTitle_" + languageId); } } portletSetup.setValue("portletSetupUseCustomTitle", String.valueOf(useCustomTitle)); if (Validator.isNotNull(linkToLayoutUuid)) { portletSetup.setValue("portletSetupLinkToLayoutUuid", linkToLayoutUuid); } else { portletSetup.reset("portletSetupLinkToLayoutUuid"); } if (Validator.isNotNull(portletDecoratorId)) { portletSetup.setValue("portletSetupPortletDecoratorId", portletDecoratorId); } else { portletSetup.reset("portletSetupPortletDecoratorId"); } portletSetup.setValue("portletSetupCss", css); portletSetup.store(); }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void deleteArchivedSetups(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] names = null;//from w w w . ja va 2s . com String name = ParamUtil.getString(actionRequest, "name"); if (Validator.isNotNull(name)) { names = new String[] { name }; } else { names = ParamUtil.getStringValues(actionRequest, "rowIds"); } for (String curName : names) { ArchivedSettings archivedSettings = SettingsFactoryUtil.getPortletInstanceArchivedSettings( themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), curName); archivedSettings.delete(); } }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void restoreArchivedSetup(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Settings portletInstanceSettings = SettingsFactoryUtil .getSettings(new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portlet.getPortletId())); ModifiableSettings portletInstanceModifiableSettings = portletInstanceSettings.getModifiableSettings(); String name = ParamUtil.getString(actionRequest, "name"); ArchivedSettings archivedSettings = SettingsFactoryUtil.getPortletInstanceArchivedSettings( themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), name); portletInstanceModifiableSettings.reset(); portletInstanceModifiableSettings.setValues(archivedSettings); portletInstanceModifiableSettings.store(); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add(actionRequest,//from w ww.j av a 2s . c om _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void updateArchivedSetup(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String name = ParamUtil.getString(actionRequest, "name"); ArchivedSettings archivedSettings = SettingsFactoryUtil.getPortletInstanceArchivedSettings( themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), name); Settings portletInstanceSettings = SettingsFactoryUtil .getSettings(new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portlet.getPortletId())); ModifiableSettings portletInstanceModifiableSettings = portletInstanceSettings.getModifiableSettings(); archivedSettings.setValues(portletInstanceModifiableSettings); archivedSettings.store();/*w w w.j a v a 2 s. c o m*/ }