List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPlid
public long getPlid()
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(); }/*www .j a va2 s . c om*/ 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.bookmarks.web.internal.portlet.toolbar.contributor.BookmarksPortletToolbarContributor.java
License:Open Source License
protected void addPortletTitleAddBookmarkMenuItem(List<MenuItem> menuItems, BookmarksFolder folder, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { long folderId = _getFolderId(folder); if (!containsPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), folderId, ActionKeys.ADD_ENTRY)) {// w w w. j a va 2 s . com return; } URLMenuItem urlMenuItem = new URLMenuItem(); urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), "bookmark")); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/bookmarks/edit_entry"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("folderId", String.valueOf(folderId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
From source file:com.liferay.bookmarks.web.internal.portlet.toolbar.contributor.BookmarksPortletToolbarContributor.java
License:Open Source License
protected void addPortletTitleAddFolderMenuItem(List<MenuItem> menuItems, BookmarksFolder folder, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { long folderId = _getFolderId(folder); if (!containsPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), folderId, ActionKeys.ADD_FOLDER)) {//from www . ja v a2 s .c o m return; } URLMenuItem urlMenuItem = new URLMenuItem(); urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), (folder != null) ? "subfolder" : "folder")); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/bookmarks/edit_folder"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("parentFolderId", String.valueOf(folderId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java
License:Open Source License
protected String getViewCalendarBookingURL(ActionRequest actionRequest, CalendarBooking calendarBooking) throws WindowStateException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest, themeDisplay.getPpid(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); redirectURL.setParameter("mvcPath", "/view_calendar_booking.jsp"); redirectURL.setParameter("calendarBookingId", String.valueOf(calendarBooking.getCalendarBookingId())); redirectURL.setParameter("instanceIndex", "0"); redirectURL.setWindowState(LiferayWindowState.POP_UP); return redirectURL.toString(); }
From source file:com.liferay.document.library.web.portlet.action.UploadAssignmentMVCActionCommand.java
License:Open Source License
protected String getErrorRedirect(PortletConfig portletConfig, ActionRequest actionRequest, String redirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletURLImpl portletURL = new PortletURLImpl(actionRequest, portletConfig.getPortletName(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/document_library/upload_assignment"); portletURL.setParameter("redirect", redirect, false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
From source file:com.liferay.exportimport.changeset.web.internal.portlet.action.ExportImportEntityMVCActionCommand.java
License:Open Source License
private void _processExportAndPublishAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortalException { String[] exportingEntities;//from w w w . j a va2s . c o m if (Validator.isNotNull(actionRequest.getParameter("exportingEntities"))) { exportingEntities = ParamUtil.getStringValues(actionRequest, "exportingEntities"); } else if (Validator.isNotNull(actionRequest.getParameter("classNameId")) && Validator.isNotNull(actionRequest.getParameter("uuid"))) { long classNameId = ParamUtil.getLong(actionRequest, "classNameId"); long groupId = ParamUtil.getLong(actionRequest, "groupId"); String uuid = ParamUtil.getString(actionRequest, "uuid"); StringBundler sb = new StringBundler(5); sb.append(classNameId); sb.append(StringPool.POUND); sb.append(groupId); sb.append(StringPool.POUND); sb.append(uuid); exportingEntities = new String[] { sb.toString() }; } else { SessionErrors.add(actionRequest, ExportImportEntityException.class, new ExportImportEntityException(ExportImportEntityException.TYPE_NO_DATA_FOUND)); return; } Map<String, String[]> parameterMap = ExportImportConfigurationParameterMapFactory.buildParameterMap(); parameterMap.put("exportingEntities", exportingEntities); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(actionRequest, "cmd"); String portletId = MapUtil.getString(actionRequest.getParameterMap(), "portletId"); Portlet portlet = _portletLocalService.getPortletById(portletId); long backgroundTaskId = 0; if (cmd.equals(Constants.EXPORT)) { Map<String, Serializable> settingsMap = ExportImportConfigurationSettingsMapFactory .buildExportPortletSettingsMap(themeDisplay.getUser(), themeDisplay.getPlid(), themeDisplay.getScopeGroupId(), ChangesetPortletKeys.CHANGESET, parameterMap, _exportImportHelper.getPortletExportFileName(portlet)); ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService .addDraftExportImportConfiguration(themeDisplay.getUserId(), portletId, ExportImportConfigurationConstants.TYPE_EXPORT_PORTLET, settingsMap); backgroundTaskId = _exportImportLocalService .exportPortletInfoAsFileInBackground(themeDisplay.getUserId(), exportImportConfiguration); } else if (cmd.equals(Constants.PUBLISH)) { Group scopeGroup = themeDisplay.getScopeGroup(); if (!scopeGroup.isStagingGroup() && !scopeGroup.isStagedRemotely()) { SessionErrors.add(actionRequest, ExportImportEntityException.class, new ExportImportEntityException(ExportImportEntityException.TYPE_GROUP_NOT_STAGED)); return; } if (!scopeGroup.isStagedPortlet(portletId)) { SessionErrors.add(actionRequest, ExportImportEntityException.class, new ExportImportEntityException(ExportImportEntityException.TYPE_PORTLET_NOT_STAGED)); return; } long liveGroupId = 0; if (scopeGroup.isStagingGroup()) { liveGroupId = scopeGroup.getLiveGroupId(); } else if (scopeGroup.isStagedRemotely()) { liveGroupId = scopeGroup.getRemoteLiveGroupId(); } Map<String, Serializable> settingsMap = ExportImportConfigurationSettingsMapFactory .buildPublishPortletSettingsMap(themeDisplay.getUser(), themeDisplay.getScopeGroupId(), themeDisplay.getPlid(), liveGroupId, themeDisplay.getPlid(), ChangesetPortletKeys.CHANGESET, parameterMap); ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService .addDraftExportImportConfiguration(themeDisplay.getUserId(), portletId, ExportImportConfigurationConstants.TYPE_PUBLISH_PORTLET, settingsMap); backgroundTaskId = _staging.publishPortlet(themeDisplay.getUserId(), exportImportConfiguration); } sendRedirect(actionRequest, actionResponse, backgroundTaskId); }
From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java
License:Open Source License
@Override public long getPlid() { ThemeDisplay themeDisplay = getThemeDisplay(); return themeDisplay.getPlid(); }
From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java
License:Open Source License
@Override public ServiceContext getServiceContext() { ServiceContext serviceContext = new ServiceContext(); ThemeDisplay themeDisplay = getThemeDisplay(); serviceContext.setCompanyId(themeDisplay.getCompanyId()); serviceContext.setLanguageId(themeDisplay.getLanguageId()); serviceContext.setPathMain(PortalUtil.getPathMain()); serviceContext.setPlid(themeDisplay.getPlid()); serviceContext.setPortalURL(PortalUtil.getPortalURL(getPortletRequest())); serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId()); serviceContext.setUserId(themeDisplay.getUserId()); try {/*w w w. ja v a 2 s . c om*/ serviceContext.setLayoutFullURL(PortalUtil.getLayoutFullURL(themeDisplay)); serviceContext.setLayoutURL(PortalUtil.getLayoutURL(themeDisplay)); serviceContext.setUserDisplayURL(themeDisplay.getUser().getDisplayURL(themeDisplay)); } catch (Exception e) { logger.error(e.getMessage(), e); } return serviceContext; }
From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java
License:Open Source License
@Override public boolean userHasPortletPermission(String actionId) { ThemeDisplay themeDisplay = getThemeDisplay(); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); boolean hasPermission = false; try {/* ww w . j a va 2 s . c o m*/ hasPermission = PortletPermissionUtil.contains(permissionChecker, themeDisplay.getPlid(), portletId, actionId); } catch (Exception e) { logger.error(e.getMessage(), e); } return hasPermission; }
From source file:com.liferay.journal.content.web.internal.portlet.toolbar.contributor.JournalContentPortletToolbarContributor.java
License:Open Source License
protected void addPortletTitleAddJournalArticleMenuItems(List<MenuItem> menuItems, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws Exception { long plid = themeDisplay.getPlid(); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); long scopeGroupId = themeDisplay.getScopeGroupId(); PortletURL portletURL = _portal.getControlPanelPortletURL(portletRequest, JournalPortletKeys.JOURNAL, PortletRequest.RENDER_PHASE); portletURL.setParameter("hideDefaultSuccessMessage", Boolean.TRUE.toString()); portletURL.setParameter("groupId", String.valueOf(scopeGroupId)); portletURL.setParameter("mvcPath", "/edit_article.jsp"); portletURL.setParameter("portletResource", portletDisplay.getId()); portletURL.setParameter("redirect", _getAddJournalArticleRedirectURL(themeDisplay, portletRequest)); portletURL.setParameter("referringPlid", String.valueOf(plid)); portletURL.setParameter("showHeader", Boolean.FALSE.toString()); portletURL.setWindowState(LiferayWindowState.POP_UP); List<DDMStructure> ddmStructures = _journalFolderService.getDDMStructures( _portal.getCurrentAndAncestorSiteGroupIds(scopeGroupId), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, JournalFolderConstants.RESTRICTION_TYPE_INHERIT); for (DDMStructure ddmStructure : ddmStructures) { portletURL.setParameter("ddmStructureId", String.valueOf(ddmStructure.getStructureId())); URLMenuItem urlMenuItem = new URLMenuItem(); String ddmStructureName = ddmStructure.getName(themeDisplay.getLocale()); String title = LanguageUtil.format(themeDisplay.getLocale(), "new-x", ddmStructureName); Map<String, Object> data = new HashMap<>(); data.put("id", HtmlUtil.escape(portletDisplay.getNamespace()) + "editAsset"); data.put("title", HtmlUtil.escape(title)); urlMenuItem.setData(data);/*from w w w .ja v a 2 s. co m*/ String label = ddmStructure.getUnambiguousName(ddmStructures, themeDisplay.getScopeGroupId(), themeDisplay.getLocale()); urlMenuItem.setLabel(label); urlMenuItem.setURL(portletURL.toString()); urlMenuItem.setUseDialog(true); menuItems.add(urlMenuItem); } }