List of usage examples for com.liferay.portal.kernel.util PortalUtil getPortletId
public static String getPortletId(PortletRequest portletRequest)
From source file:ca.efendi.datafeeds.web.util.CJProductURLHelper.java
License:Apache License
public PortletURL createViewURL(final CJProduct cjProduct) throws PortalException { final PortletURL portletURL = _renderResponse.createRenderURL(); final String portletId = PortalUtil.getPortletId(_renderRequest); if (portletId.startsWith(PortletKeys.T_DATAFEEDS_ADMIN) || portletId.startsWith(PortletKeys.T_DATAFEEDS_SEARCH)) { portletURL.setParameter("mvcPath", _templatePath + "view_cjproduct.jsp"); }//from w w w . j a va 2s.c o m if (portletId.startsWith(PortletKeys.T_DATAFEEDS_ADMIN)) { portletURL.setParameter("redirect", PortalUtil.getCurrentURL(_renderRequest)); } if (portletId.equals(PortletKeys.T_DATAFEEDS_ADMIN)) { portletURL.setParameter("resourceClassNameId", String.valueOf(PortalUtil.getClassNameId(CJProduct.class.getName()))); portletURL.setParameter("resourcePrimKey", String.valueOf(cjProduct.getPrimaryKey())); } else { portletURL.setParameter("urlTitle", cjProduct.getName()); } return portletURL; }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
public static void addAndStoreSelection(PortletRequest portletRequest, String className, long classPK, int assetEntryOrder) throws Exception { String portletId = PortalUtil.getPortletId(portletRequest); String rootPortletId = PortletIdCodec.decodePortletName(portletId); if (!rootPortletId.equals(AssetPublisherPortletKeys.ASSET_PUBLISHER)) { return;/*from ww w . j ava 2s .c o m*/ } ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout, portletId); if (portletPreferences instanceof StrictPortletPreferencesImpl) { return; } String selectionStyle = portletPreferences.getValue("selectionStyle", "dynamic"); if (selectionStyle.equals("dynamic")) { return; } AssetEntry assetEntry = _assetEntryLocalService.getEntry(className, classPK); addSelection(themeDisplay, portletPreferences, portletId, assetEntry.getEntryId(), assetEntryOrder, className); portletPreferences.store(); }
From source file:com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand.java
License:Open Source License
protected void deleteEntries(ActionRequest actionRequest, boolean moveToTrash) throws Exception { long[] deleteEntryIds = null; long entryId = ParamUtil.getLong(actionRequest, "entryId"); if (entryId > 0) { deleteEntryIds = new long[] { entryId }; } else {/*from w w w . j a v a 2 s . c o m*/ deleteEntryIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteEntryIds"), 0L); } List<TrashedModel> trashedModels = new ArrayList<>(); for (long deleteEntryId : deleteEntryIds) { if (moveToTrash) { BlogsEntry entry = _blogsEntryService.moveEntryToTrash(deleteEntryId); trashedModels.add(entry); } else { _blogsEntryService.deleteEntry(deleteEntryId); } } if (moveToTrash && !trashedModels.isEmpty()) { TrashUtil.addTrashSessionMessages(actionRequest, trashedModels); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE); } }
From source file:com.liferay.document.library.web.internal.util.IGUtil.java
License:Open Source License
protected static long getRootFolderId(HttpServletRequest request) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletPreferences(request, PortalUtil.getPortletId(request)); return GetterUtil.getLong(portletPreferences.getValue("rootFolderId", String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID))); }
From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.action.DDMBaseMVCActionCommand.java
License:Open Source License
protected String getRedirect(ActionRequest actionRequest) { String redirect = ParamUtil.getString(actionRequest, "redirect"); String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect"); if (Validator.isNull(closeRedirect)) { return redirect; }//w w w. j a va 2 s . c o m redirect = HttpUtil.setParameter(redirect, "closeRedirect", closeRedirect); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect); return redirect; }
From source file:com.liferay.faces.bridge.ext.filter.internal.LiferayPortalUtil.java
License:Open Source License
public static String getPortletId(PortletRequest portletRequest) { String portletId = null;/*w ww . j ava 2 s. com*/ try { portletId = PortalUtil.getPortletId(portletRequest); if (portletRequest.getParameter("wsrp") != null) { // For some reason, when running as a WSRP producer, the underscores are missing from the beginning // and end... portletId = "_" + portletId + "_"; } } catch (Exception e) { logger.error(e); } return portletId; }
From source file:com.liferay.staging.bar.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static void addLayoutBranchSessionMessages(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { if (SessionErrors.isEmpty(actionRequest)) { SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, StagingBarPortletKeys.STAGING_BAR); Map<String, String> data = new HashMap<>(); data.put("preventNotification", Boolean.TRUE.toString()); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET_DATA, data); }/* w ww .java 2s .com*/ String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); actionResponse.sendRedirect(redirect); }
From source file:com.liferay.trash.web.internal.util.TrashUndoUtil.java
License:Open Source License
public static void addRestoreData(ActionRequest actionRequest, List<ObjectValuePair<String, Long>> entries) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if ((entries == null) || entries.isEmpty()) { return;/*from w ww . java2s . c om*/ } List<String> restoreClassNames = new ArrayList<>(); List<String> restoreEntryLinks = new ArrayList<>(); List<String> restoreEntryMessages = new ArrayList<>(); List<String> restoreLinks = new ArrayList<>(); List<String> restoreMessages = new ArrayList<>(); for (ObjectValuePair<String, Long> entry : entries) { TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(entry.getKey()); String restoreEntryLink = trashHandler.getRestoreContainedModelLink(actionRequest, entry.getValue()); String restoreLink = trashHandler.getRestoreContainerModelLink(actionRequest, entry.getValue()); String restoreMessage = trashHandler.getRestoreMessage(actionRequest, entry.getValue()); if (Validator.isNull(restoreLink) || Validator.isNull(restoreMessage)) { continue; } restoreClassNames.add(trashHandler.getClassName()); restoreEntryLinks.add(restoreEntryLink); TrashRenderer trashRenderer = trashHandler.getTrashRenderer(entry.getValue()); String restoreEntryTitle = trashRenderer.getTitle(themeDisplay.getLocale()); restoreEntryMessages.add(restoreEntryTitle); restoreLinks.add(restoreLink); restoreMessages.add(restoreMessage); } Map<String, List<String>> data = new HashMap<>(); data.put("restoreClassNames", restoreClassNames); data.put("restoreEntryLinks", restoreEntryLinks); data.put("restoreEntryMessages", restoreEntryMessages); data.put("restoreLinks", restoreLinks); data.put("restoreMessages", restoreMessages); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_DELETE_SUCCESS_DATA, data); }