List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId
public long getScopeGroupId()
From source file:com.liferay.site.teams.web.internal.display.context.SiteTeamsDisplayContext.java
License:Open Source License
public SearchContainer getSearchContainer() throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); SearchContainer searchContainer = new TeamSearch(_renderRequest, getPortletURL()); searchContainer.setEmptyResultsMessage("there-are-no-site-teams"); if (Validator.isNull(getKeywords())) { if (isShowAddButton()) { searchContainer.setEmptyResultsMessage("there-are-no-site-teams.-you-can-add-a-site-team-by-" + "clicking-the-plus-button-on-the-bottom-right-corner"); searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); }/*from w w w .j av a 2s . c om*/ } else { searchContainer.setSearch(true); } searchContainer.setId("teams"); searchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse)); searchContainer.setTotal(getTotal()); List results = TeamServiceUtil.search(themeDisplay.getScopeGroupId(), getKeywords(), getKeywords(), new LinkedHashMap<String, Object>(), searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator()); searchContainer.setResults(results); return searchContainer; }
From source file:com.liferay.site.teams.web.internal.display.context.SiteTeamsDisplayContext.java
License:Open Source License
protected int getTotal() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); return TeamServiceUtil.searchCount(themeDisplay.getScopeGroupId(), getKeywords(), getKeywords(), new LinkedHashMap<String, Object>()); }
From source file:com.liferay.social.activities.web.internal.portlet.action.RSSMVCResourceCommand.java
License:Open Source License
@Override protected byte[] getRSS(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); String tabs1 = ParamUtil.getString(resourceRequest, "tabs1", "all"); String feedTitle = ParamUtil.getString(resourceRequest, "feedTitle"); String format = ParamUtil.getString(resourceRequest, "type", RSSUtil.FORMAT_DEFAULT); double version = ParamUtil.getDouble(resourceRequest, "version", RSSUtil.VERSION_DEFAULT); String displayStyle = ParamUtil.getString(resourceRequest, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT); int max = ParamUtil.getInteger(resourceRequest, "max", SearchContainer.DEFAULT_DELTA); Group group = _groupLocalService.getGroup(themeDisplay.getScopeGroupId()); SocialActivitiesQueryHelper.Scope scope = SocialActivitiesQueryHelper.Scope.fromValue(tabs1); List<SocialActivitySet> socialActivitySets = _socialActivitiesQueryHelper.getSocialActivitySets(group, themeDisplay.getLayout(), scope, 0, max); ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest); String rss = exportToRSS(resourceRequest, resourceResponse, feedTitle, null, format, version, displayStyle, socialActivitySets, serviceContext); return rss.getBytes(StringPool.UTF8); }
From source file:com.liferay.social.activity.web.internal.portlet.action.ViewMVCRenderCommand.java
License:Open Source License
protected Map<String, Boolean> getActivitySettingsMap(ThemeDisplay themeDisplay) throws Exception { Map<String, Boolean> activitySettingsMap = new LinkedHashMap<>(); List<SocialActivitySetting> activitySettings = _socialActivitySettingService .getActivitySettings(themeDisplay.getSiteGroupIdOrLiveGroupId()); String[] modelNames = SocialConfigurationUtil.getActivityModelNames(); Comparator<String> comparator = new ModelResourceComparator(themeDisplay.getLocale()); Arrays.sort(modelNames, comparator); for (String modelName : modelNames) { List<SocialActivityDefinition> activityDefinitions = _socialActivitySettingService .getActivityDefinitions(themeDisplay.getScopeGroupId(), modelName); for (SocialActivityDefinition activityDefinition : activityDefinitions) { if (activityDefinition.isCountersEnabled()) { activitySettingsMap.put(modelName, false); break; }//from www.ja va2 s. c o m } } for (SocialActivitySetting activitySetting : activitySettings) { String name = activitySetting.getName(); if (name.equals("enabled") && activitySettingsMap.containsKey(activitySetting.getClassName())) { activitySettingsMap.put(activitySetting.getClassName(), GetterUtil.getBoolean(activitySetting.getValue())); } } return activitySettingsMap; }
From source file:com.liferay.social.requests.web.internal.portlet.action.ViewMVCRenderCommand.java
License:Open Source License
protected String doRender(RenderRequest renderRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); Group group = _groupLocalService.getGroup(themeDisplay.getScopeGroupId()); User user = themeDisplay.getUser();/* ww w. j a v a2 s . c o m*/ if (group.isUser()) { user = _userLocalService.getUserById(group.getClassPK()); } if (UserPermissionUtil.contains(themeDisplay.getPermissionChecker(), user.getUserId(), ActionKeys.UPDATE)) { List<SocialRequest> requests = _socialRequestLocalService.getReceiverUserRequests(user.getUserId(), SocialRequestConstants.STATUS_PENDING, 0, 100); renderRequest.setAttribute(SocialRequestsWebKeys.SOCIAL_REQUESTS, requests); } return "/view.jsp"; }
From source file:com.liferay.tool.datamanipulator.portlet.DataManipulatorAdmin.java
License:Open Source License
public void create(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); RequestContext requestContext = new RequestContext(uploadRequest); ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY); String handlerName = ParamUtil.getString(uploadRequest, "handlerName"); BaseHandler handler = HandlerUtil.getHandler(handlerName); boolean handlerIsPortalType = HandlerUtil.isPortalType(handlerName); long[] groupIds = requestContext.getGroupIds(); if ((groupIds.length <= 0) || handlerIsPortalType) { groupIds = new long[] { themeDisplay.getScopeGroupId() }; }/*from w w w. j a v a 2 s . c o m*/ long[] userIds = requestContext.getUserIds(); if ((userIds.length <= 0) || handlerIsPortalType) { userIds = new long[] { themeDisplay.getUserId() }; } for (long groupId : groupIds) { for (long userId : userIds) { requestContext = new RequestContext(uploadRequest); requestContext.setGroupId(groupId); requestContext.setUserId(userId); HandlerThread handlerThread = new HandlerThread(handler, requestContext); handlerThread.start(); } } }
From source file:com.liferay.trash.web.internal.portlet.TrashPortlet.java
License:Open Source License
public void emptyTrash(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId", themeDisplay.getScopeGroupId()); _trashEntryService.deleteEntries(groupId); }
From source file:com.liferay.trash.web.internal.portlet.TrashViewPortletProvider.java
License:Open Source License
@Override public PortletURL getPortletURL(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String portletId = PortletProviderUtil.getPortletId(TrashEntry.class.getName(), PortletProvider.Action.VIEW); if (!themeDisplay.isSignedIn() || !_trashHelper.isTrashEnabled(themeDisplay.getScopeGroupId()) || !PortletPermissionUtil.hasControlPanelAccessPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) { return null; }/*from w w w . j a v a 2s . c o m*/ PortletURL portletURL = _portal.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE); portletURL.setParameter("redirect", themeDisplay.getURLCurrent()); return portletURL; }
From source file:com.liferay.users.admin.web.internal.portlet.action.EditUserMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { actionRequest = _wrapActionRequest(actionRequest); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {//from w ww . ja va 2s . co m User user = null; String oldScreenName = StringPool.BLANK; boolean updateLanguageId = false; if (cmd.equals(Constants.ADD)) { user = addUser(actionRequest); } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.DELETE) || cmd.equals(Constants.RESTORE)) { deleteUsers(actionRequest); } else if (cmd.equals("deleteRole")) { deleteRole(actionRequest); } else if (cmd.equals(Constants.UPDATE)) { Object[] returnValue = updateUser(actionRequest, actionResponse); user = (User) returnValue[0]; oldScreenName = (String) returnValue[1]; updateLanguageId = (Boolean) returnValue[2]; } else if (cmd.equals("unlock")) { user = updateLockout(actionRequest); } ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String redirect = ParamUtil.getString(actionRequest, "redirect"); if (user != null) { if (Validator.isNotNull(oldScreenName)) { // This will fix the redirect if the user is on his personal // my account page and changes his screen name. A redirect // that references the old screen name no longer points to a // valid screen name and therefore needs to be updated. Group group = user.getGroup(); if (group.getGroupId() == themeDisplay.getScopeGroupId()) { Layout layout = themeDisplay.getLayout(); String friendlyURLPath = group.getPathFriendlyURL(layout.isPrivateLayout(), themeDisplay); String oldPath = friendlyURLPath + StringPool.SLASH + oldScreenName; String newPath = friendlyURLPath + StringPool.SLASH + user.getScreenName(); redirect = StringUtil.replace(redirect, oldPath, newPath); redirect = StringUtil.replace(redirect, URLCodec.encodeURL(oldPath), URLCodec.encodeURL(newPath)); } } if (updateLanguageId && themeDisplay.isI18n()) { String i18nLanguageId = user.getLanguageId(); int pos = i18nLanguageId.indexOf(CharPool.UNDERLINE); if (pos != -1) { i18nLanguageId = i18nLanguageId.substring(0, pos); } String i18nPath = StringPool.SLASH + i18nLanguageId; redirect = StringUtil.replace(redirect, themeDisplay.getI18nPath(), i18nPath); } redirect = http.setParameter(redirect, actionResponse.getNamespace() + "p_u_i_d", user.getUserId()); } Group scopeGroup = themeDisplay.getScopeGroup(); if (scopeGroup.isUser() && (userLocalService.fetchUserById(scopeGroup.getClassPK()) == null)) { redirect = http.setParameter(redirect, "doAsGroupId", 0); redirect = http.setParameter(redirect, "refererPlid", 0); } sendRedirect(actionRequest, actionResponse, redirect); } catch (Exception e) { String mvcPath = "/edit_user.jsp"; if (e instanceof NoSuchUserException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); mvcPath = "/error.jsp"; } else if (e instanceof AssetCategoryException || e instanceof AssetTagException || e instanceof CompanyMaxUsersException || e instanceof ContactBirthdayException || e instanceof ContactNameException || e instanceof GroupFriendlyURLException || e instanceof MembershipPolicyException || e instanceof NoSuchListTypeException || e instanceof RequiredUserException || e instanceof UserEmailAddressException || e instanceof UserFieldException || e instanceof UserIdException || e instanceof UserReminderQueryException || e instanceof UserScreenNameException) { if (e instanceof NoSuchListTypeException) { NoSuchListTypeException nslte = (NoSuchListTypeException) e; Class<?> clazz = e.getClass(); SessionErrors.add(actionRequest, clazz.getName() + nslte.getType()); } else { SessionErrors.add(actionRequest, e.getClass(), e); } if (e instanceof CompanyMaxUsersException || e instanceof RequiredUserException) { String redirect = portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { sendRedirect(actionRequest, actionResponse, redirect); return; } } } else { throw e; } actionResponse.setRenderParameter("mvcPath", mvcPath); } }
From source file:com.liferay.wiki.web.internal.display.context.DefaultWikiListPagesDisplayContext.java
License:Open Source License
@Override public void populateResultsAndTotal(SearchContainer searchContainer) throws PortalException { WikiPage page = (WikiPage) _request.getAttribute(WikiWebKeys.WIKI_PAGE); ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); String navigation = ParamUtil.getString(_request, "navigation", "all-pages"); String keywords = ParamUtil.getString(_request, "keywords"); int total = 0; List<WikiPage> results = new ArrayList<>(); if (Validator.isNotNull(keywords)) { Indexer<WikiPage> indexer = IndexerRegistryUtil.getIndexer(WikiPage.class); SearchContext searchContext = SearchContextFactory.getInstance(_request); searchContext.setAttribute("paginationType", "more"); searchContext.setEnd(searchContainer.getEnd()); searchContext.setIncludeAttachments(true); searchContext.setIncludeDiscussions(true); searchContext.setKeywords(keywords); searchContext.setNodeIds(new long[] { _wikiNode.getNodeId() }); searchContext.setStart(searchContainer.getStart()); Hits hits = indexer.search(searchContext); searchContainer.setTotal(hits.getLength()); List<SearchResult> searchResults = SearchResultUtil.getSearchResults(hits, themeDisplay.getLocale()); for (SearchResult searchResult : searchResults) { WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(searchResult.getClassPK()); results.add(wikiPage);/*w ww. j a v a 2 s . c om*/ } } else if (navigation.equals("all-pages")) { total = WikiPageServiceUtil.getPagesCount(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), true, themeDisplay.getUserId(), true, WorkflowConstants.STATUS_APPROVED); searchContainer.setTotal(total); OrderByComparator<WikiPage> obc = WikiPortletUtil .getPageOrderByComparator(searchContainer.getOrderByCol(), searchContainer.getOrderByType()); results = WikiPageServiceUtil.getPages(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), true, themeDisplay.getUserId(), true, WorkflowConstants.STATUS_APPROVED, searchContainer.getStart(), searchContainer.getEnd(), obc); } else if (navigation.equals("categorized-pages") || navigation.equals("tagged-pages")) { AssetEntryQuery assetEntryQuery = new AssetEntryQuery(WikiPage.class.getName(), searchContainer); assetEntryQuery.setEnablePermissions(true); total = AssetEntryServiceUtil.getEntriesCount(assetEntryQuery); searchContainer.setTotal(total); assetEntryQuery.setEnd(searchContainer.getEnd()); assetEntryQuery.setStart(searchContainer.getStart()); List<AssetEntry> assetEntries = AssetEntryServiceUtil.getEntries(assetEntryQuery); for (AssetEntry assetEntry : assetEntries) { WikiPageResource pageResource = WikiPageResourceLocalServiceUtil .getPageResource(assetEntry.getClassPK()); WikiPage assetPage = WikiPageLocalServiceUtil.getPage(pageResource.getNodeId(), pageResource.getTitle()); results.add(assetPage); } } else if (navigation.equals("draft-pages") || navigation.equals("pending-pages")) { long draftUserId = themeDisplay.getUserId(); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())) { draftUserId = 0; } int status = WorkflowConstants.STATUS_DRAFT; if (navigation.equals("pending-pages")) { status = WorkflowConstants.STATUS_PENDING; } total = WikiPageServiceUtil.getPagesCount(themeDisplay.getScopeGroupId(), draftUserId, _wikiNode.getNodeId(), status); searchContainer.setTotal(total); results = WikiPageServiceUtil.getPages(themeDisplay.getScopeGroupId(), draftUserId, _wikiNode.getNodeId(), status, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("frontpage")) { WikiWebComponentProvider wikiWebComponentProvider = WikiWebComponentProvider .getWikiWebComponentProvider(); WikiGroupServiceConfiguration wikiGroupServiceConfiguration = wikiWebComponentProvider .getWikiGroupServiceConfiguration(); WikiPage wikiPage = WikiPageServiceUtil.getPage(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), wikiGroupServiceConfiguration.frontPageName()); searchContainer.setTotal(1); results.add(wikiPage); } else if (navigation.equals("history")) { total = WikiPageLocalServiceUtil.getPagesCount(page.getNodeId(), page.getTitle()); searchContainer.setTotal(total); results = WikiPageLocalServiceUtil.getPages(page.getNodeId(), page.getTitle(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, new PageVersionComparator()); } else if (navigation.equals("incoming-links")) { List<WikiPage> links = WikiPageLocalServiceUtil.getIncomingLinks(page.getNodeId(), page.getTitle()); total = links.size(); searchContainer.setTotal(total); results = ListUtil.subList(links, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("orphan-pages")) { List<WikiPage> orphans = WikiPageServiceUtil.getOrphans(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId()); total = orphans.size(); searchContainer.setTotal(total); results = ListUtil.subList(orphans, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("outgoing-links")) { List<WikiPage> links = WikiPageLocalServiceUtil.getOutgoingLinks(page.getNodeId(), page.getTitle()); total = links.size(); searchContainer.setTotal(total); results = ListUtil.subList(links, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("recent-changes")) { total = WikiPageServiceUtil.getRecentChangesCount(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId()); searchContainer.setTotal(total); results = WikiPageServiceUtil.getRecentChanges(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), searchContainer.getStart(), searchContainer.getEnd()); } searchContainer.setResults(results); }