List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY
String THEME_DISPLAY
To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.
Click Source Link
From source file:com.liferay.adaptive.media.web.internal.portlet.configuration.icon.OptimizeImagesPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!permissionChecker.isCompanyAdmin()) { return false; }/*from ww w . j a v a 2s . co m*/ int backgroundTasksCount = _backgroundTaskManager.getBackgroundTasksCount(CompanyConstants.SYSTEM, OptimizeImagesAllConfigurationsBackgroundTaskExecutor.class.getName(), false); if (backgroundTasksCount != 0) { return false; } Collection<AdaptiveMediaImageConfigurationEntry> configurationEntries = _configurationHelper .getAdaptiveMediaImageConfigurationEntries(themeDisplay.getCompanyId()); if (configurationEntries.isEmpty()) { return false; } return true; }
From source file:com.liferay.adaptive.media.web.internal.portlet.configuration.icon.ResetDefaultValuesPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!permissionChecker.isCompanyAdmin()) { return false; }// w w w . ja va 2 s . co m if (_adaptiveMediaImageConfigurationHelper.isDefaultConfiguration(themeDisplay.getCompanyId())) { return false; } int backgroundTasksCount = _backgroundTaskManager.getBackgroundTasksCount(CompanyConstants.SYSTEM, OptimizeImagesAllConfigurationsBackgroundTaskExecutor.class.getName(), false); if (backgroundTasksCount != 0) { return false; } return true; }
From source file:com.liferay.akismet.akismet.portlet.AkismetPortlet.java
License:Open Source License
public void updateConfiguration(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String apiKey = ParamUtil.getString(actionRequest, "apiKey"); int checkThreshold = ParamUtil.getInteger(actionRequest, "checkThreshold"); boolean discussionsEnabled = ParamUtil.getBoolean(actionRequest, "discussionsEnabled"); boolean messageBoardsEnabled = ParamUtil.getBoolean(actionRequest, "messageBoardsEnabled"); int reportableTime = ParamUtil.getInteger(actionRequest, "reportableTime"); boolean wikiEnabled = ParamUtil.getBoolean(actionRequest, "wikiEnabled"); PortletPreferences preferences = PrefsPortletPropsUtil.getPortletPreferences(themeDisplay.getCompanyId()); preferences.setValue(PortletPropsKeys.AKISMET_API_KEY, apiKey); preferences.setValue(PortletPropsKeys.AKISMET_CHECK_THRESHOLD, String.valueOf(checkThreshold)); preferences.setValue(PortletPropsKeys.AKISMET_DISCUSSIONS_CHECK_ENABLED, String.valueOf(discussionsEnabled)); preferences.setValue(PortletPropsKeys.AKISMET_MESSAGE_BOARDS_CHECK_ENABLED, String.valueOf(messageBoardsEnabled)); preferences.setValue(PortletPropsKeys.AKISMET_REPORTABLE_TIME, String.valueOf(reportableTime)); preferences.setValue(PortletPropsKeys.AKISMET_WIKI_CHECK_ENABLED, String.valueOf(wikiEnabled)); preferences.store();// w ww . j a v a 2 s . c o m if (!AkismetUtil.verifyApiKey(themeDisplay.getCompanyId(), apiKey)) { SessionErrors.add(actionRequest, "apiKeyError"); } }
From source file:com.liferay.akismet.akismet.portlet.AkismetPortlet.java
License:Open Source License
@Override protected boolean isProcessPortletRequest(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); try {//from w ww.j a va2 s. c o m if (RoleLocalServiceUtil.hasUserRole(themeDisplay.getUserId(), themeDisplay.getCompanyId(), RoleConstants.ADMINISTRATOR, true)) { return true; } } catch (Exception e) { } return false; }
From source file:com.liferay.akismet.hook.action.AkismetEditDiscussionAction.java
License:Open Source License
protected void checkPermission(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isCompanyAdmin()) { return;/*from w ww .ja va 2s. c o m*/ } if (permissionChecker.isGroupAdmin(themeDisplay.getScopeGroupId())) { return; } throw new PrincipalException(); }
From source file:com.liferay.akismet.hook.action.AkismetEditDiscussionAction.java
License:Open Source License
protected void updateStatus(HttpServletRequest request, HttpServletResponse response) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long messageId = ParamUtil.getLong(request, "messageId"); boolean spam = ParamUtil.getBoolean(request, "spam"); ServiceContext serviceContext = ServiceContextFactory.getInstance(request); if (spam) {// w ww. j ava 2 s. c om MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId, WorkflowConstants.STATUS_DENIED, serviceContext); if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) { AkismetUtil.submitSpam(message); } } else { MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId, WorkflowConstants.STATUS_APPROVED, serviceContext); if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) { AkismetUtil.submitHam(message); } } }
From source file:com.liferay.akismet.hook.action.AkismetEditMessageAction.java
License:Open Source License
protected void updateStatus(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); checkPermission(themeDisplay.getScopeGroupId()); long messageId = ParamUtil.getLong(actionRequest, "messageId"); boolean spam = ParamUtil.getBoolean(actionRequest, "spam"); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); if (spam) {// w ww .ja v a 2s. c o m MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId, WorkflowConstants.STATUS_DENIED, serviceContext); if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) { AkismetUtil.submitSpam(message); } } else { MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId, WorkflowConstants.STATUS_APPROVED, serviceContext); if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) { AkismetUtil.submitHam(message); } } }
From source file:com.liferay.akismet.hook.action.AkismetEditPageAction.java
License:Open Source License
protected void updateSummary(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); checkPermission(themeDisplay.getScopeGroupId()); long pageId = ParamUtil.getLong(actionRequest, "pageId"); boolean spam = ParamUtil.getBoolean(actionRequest, "spam"); WikiPage wikiPage = WikiPageLocalServiceUtil.getPageByPageId(pageId); WikiPage latestVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), false); String latestContent = null;// w w w. j a v a2 s.c o m double latestVersion = -1; if (latestVersionWikiPage != null) { latestContent = latestVersionWikiPage.getContent(); latestVersion = latestVersionWikiPage.getVersion(); } WikiPage previousVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), true); String previousContent = null; double previousVersion = -1; if (previousVersionWikiPage != null) { previousContent = previousVersionWikiPage.getContent(); previousVersion = previousVersionWikiPage.getVersion(); } String pattern = StringPool.BLANK; ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); if (spam) { pattern = "version-x-was-marked-as-spam"; // Selected version wikiPage.setStatus(WorkflowConstants.STATUS_APPROVED); wikiPage.setSummary(AkismetConstants.WIKI_PAGE_PENDING_APPROVAL); wikiPage = WikiPageLocalServiceUtil.updateWikiPage(wikiPage); // Latest version if ((wikiPage.getVersion() >= latestVersion) && (previousVersionWikiPage != null)) { WikiPageLocalServiceUtil.revertPage(themeDisplay.getUserId(), wikiPage.getNodeId(), wikiPage.getTitle(), previousVersion, serviceContext); } // Akismet if (AkismetUtil.isWikiEnabled(themeDisplay.getCompanyId())) { AkismetUtil.submitSpam(wikiPage); } } else { pattern = "version-x-was-marked-as-not-spam"; // Selected version wikiPage.setStatus(WorkflowConstants.STATUS_APPROVED); wikiPage.setSummary(StringPool.BLANK); wikiPage = WikiPageLocalServiceUtil.updateWikiPage(wikiPage); // Latest version if ((latestContent != null) && ((previousContent == null) || latestContent.equals(previousContent))) { WikiPageLocalServiceUtil.revertPage(themeDisplay.getUserId(), wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), serviceContext); } else { SessionMessages.add(actionRequest, "anotherUserHasMadeChanges"); } // Akismet if (AkismetUtil.isWikiEnabled(themeDisplay.getCompanyId())) { AkismetUtil.submitHam(wikiPage); } } String value = LanguageUtil.format(themeDisplay.getLocale(), pattern, String.valueOf(wikiPage.getVersion()), false); SessionMessages.add(actionRequest, "requestProcessed", value); }
From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java
License:Open Source License
public void deleteDiscussionMBMessages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); checkMBMessagePermission(themeDisplay.getScopeGroupId()); long[] mbMessageIds = ParamUtil.getLongValues(actionRequest, "deleteMBMessageIds"); for (long mbMessageId : mbMessageIds) { MBMessageLocalServiceUtil.deleteDiscussionMessage(mbMessageId); }/*from ww w . jav a 2 s. c o m*/ }
From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java
License:Open Source License
public void deleteMBMessages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); checkMBMessagePermission(themeDisplay.getScopeGroupId()); long[] mbMessageIds = ParamUtil.getLongValues(actionRequest, "deleteMBMessageIds"); for (long mbMessageId : mbMessageIds) { MBMessageLocalServiceUtil.deleteMessage(mbMessageId); }//from ww w.j a va 2 s . com }