List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getUserId
public long getUserId()
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 ww .j a va 2s. 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.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 www .j a va 2s . 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; }
From source file:com.liferay.message.boards.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static MBMessageDisplay getMessageDisplay(HttpServletRequest request) throws PortalException { long messageId = ParamUtil.getLong(request, "messageId"); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); int status = WorkflowConstants.STATUS_APPROVED; if (permissionChecker.isContentReviewer(themeDisplay.getUserId(), themeDisplay.getScopeGroupId())) { status = WorkflowConstants.STATUS_ANY; }/*from w w w . j av a 2s .c o m*/ MBMessageDisplay messageDisplay = MBMessageServiceUtil.getMessageDisplay(messageId, status); if (messageDisplay != null) { MBMessage message = messageDisplay.getMessage(); if ((message != null) && message.isInTrash()) { throw new NoSuchMessageException("{messageId=" + messageId + "}"); } } return messageDisplay; }
From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.CategorySubscriptionPortletConfigurationIcon.java
License:Open Source License
private boolean _isSubscribed(PortletRequest portletRequest, MBCategory category) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); return _subscriptionLocalService.isSubscribed(themeDisplay.getCompanyId(), themeDisplay.getUserId(), MBCategory.class.getName(), category.getCategoryId()); }
From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.ThreadSubscriptionPortletConfigurationIcon.java
License:Open Source License
private boolean _isSubscribed(PortletRequest portletRequest, long threadId) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); return _subscriptionLocalService.isSubscribed(themeDisplay.getCompanyId(), themeDisplay.getUserId(), MBThread.class.getName(), threadId); }
From source file:com.liferay.message.boards.web.internal.upload.TempImageMBUploadFileEntryHandler.java
License:Open Source License
@Override public FileEntry upload(UploadPortletRequest uploadPortletRequest) throws IOException, PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); long categoryId = ParamUtil.getLong(uploadPortletRequest, "categoryId"); MBCategoryPermission.check(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), categoryId, ActionKeys.ADD_FILE);//from www. j ava 2 s.c o m String fileName = uploadPortletRequest.getFileName(_PARAMETER_NAME); String contentType = uploadPortletRequest.getContentType(_PARAMETER_NAME); try (InputStream inputStream = uploadPortletRequest.getFileAsStream(_PARAMETER_NAME)) { String tempFileName = TempFileEntryUtil.getTempFileName(fileName); return TempFileEntryUtil.addTempFileEntry(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), _TEMP_FOLDER_NAME, tempFileName, inputStream, contentType); } }
From source file:com.liferay.microblogs.web.internal.portlet.MicroblogsPortlet.java
License:Open Source License
public void updateMicroblogsEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long microblogsEntryId = ParamUtil.getLong(actionRequest, "microblogsEntryId"); String content = ParamUtil.getString(actionRequest, "content"); int type = ParamUtil.getInteger(actionRequest, "type"); long parentMicroblogsEntryId = ParamUtil.getLong(actionRequest, "parentMicroblogsEntryId"); int socialRelationType = ParamUtil.getInteger(actionRequest, "socialRelationType"); ServiceContext serviceContext = ServiceContextFactory.getInstance(MicroblogsEntry.class.getName(), actionRequest);/*from w w w. j a v a 2s . c o m*/ String[] assetTagNames = getAssetTagNames(content); serviceContext.setAssetTagNames(assetTagNames); if (microblogsEntryId > 0) { microblogsEntryService.updateMicroblogsEntry(microblogsEntryId, content, socialRelationType, serviceContext); } else { microblogsEntryService.addMicroblogsEntry(themeDisplay.getUserId(), content, type, parentMicroblogsEntryId, socialRelationType, serviceContext); } }
From source file:com.liferay.microblogs.web.internal.util.MicroblogsWebUtil.java
License:Open Source License
protected static String replaceHashtags(String content, ServiceContext serviceContext) throws PortalException { String escapedContent = HtmlUtil.escape(content); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); Matcher matcher = _hashtagPattern.matcher(content); while (matcher.find()) { String result = matcher.group(); StringBuilder sb = new StringBuilder(6); sb.append("<span class=\"hashtag\">#</span>"); sb.append("<a class=\"hashtag-link\" href=\""); PortletURL portletURL = null;/*from ww w . java 2 s . c om*/ Group group = GroupLocalServiceUtil.getUserGroup(themeDisplay.getCompanyId(), themeDisplay.getUserId()); long portletPlid = PortalUtil.getPlidFromPortletId(group.getGroupId(), true, MicroblogsPortletKeys.MICROBLOGS); if (portletPlid != 0) { portletURL = PortletURLFactoryUtil.create(serviceContext.getLiferayPortletRequest(), MicroblogsPortletKeys.MICROBLOGS, portletPlid, PortletRequest.RENDER_PHASE); try { portletURL.setWindowState(LiferayWindowState.NORMAL); } catch (WindowStateException wse) { } } else { LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); portletURL = liferayPortletResponse.createRenderURL(MicroblogsPortletKeys.MICROBLOGS); try { portletURL.setWindowState(WindowState.MAXIMIZED); } catch (WindowStateException wse) { } } portletURL.setParameter("mvcPath", "/microblogs/view.jsp"); String assetTagName = result.substring(1); portletURL.setParameter("tabs1", assetTagName); portletURL.setParameter("assetTagName", assetTagName); sb.append(portletURL); sb.append("\">"); sb.append(assetTagName); sb.append("</a>"); String tagLink = sb.toString(); escapedContent = StringUtil.replace(escapedContent, result, tagLink); } return escapedContent; }
From source file:com.liferay.notifications.action.NotificationMVCActionCommand.java
License:Open Source License
@Override public void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ActionableDynamicQuery userNotificationEventActionableDynamicQuery = getUserNotificationEventActionableDynamicQuery( themeDisplay.getUserId()); userNotificationEventActionableDynamicQuery.performActions(); }
From source file:com.liferay.notifications.web.internal.portlet.configuration.icon.MarkAllNotificationsAsReadPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { if (!ParamUtil.getBoolean(portletRequest, "actionRequired")) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); int unreadNotificationEventsCount = _userNotificationEventLocalService .getArchivedUserNotificationEventsCount(themeDisplay.getUserId(), UserNotificationDeliveryConstants.TYPE_WEBSITE, false, false); if (unreadNotificationEventsCount > 0) { return true; }/*w ww. j ava 2 s .co m*/ } return false; }