List of usage examples for com.liferay.portal.kernel.servlet SessionErrors add
public static void add(PortletRequest portletRequest, String key)
From source file:com.liferay.blogs.web.internal.portlet.action.EditImageMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {//from w w w . j a v a2 s . co m if (cmd.equals(Constants.DELETE)) { deleteImages(actionRequest); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/blogs/error.jsp"); } else { throw e; } } catch (Throwable t) { _log.error(t, t); actionResponse.setRenderParameter("mvcPath", "/blogs/error.jsp"); } }
From source file:com.liferay.blogs.web.internal.portlet.action.ViewEntryMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { long assetCategoryId = ParamUtil.getLong(renderRequest, "categoryId"); String assetCategoryName = ParamUtil.getString(renderRequest, "tag"); if ((assetCategoryId > 0) || Validator.isNotNull(assetCategoryName)) { return "/blogs/view.jsp"; }//from w ww.java 2 s.com try { ActionUtil.getEntry(renderRequest); if (PropsValues.BLOGS_PINGBACK_ENABLED) { BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY); if ((entry != null) && entry.isAllowPingbacks()) { HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse); response.addHeader("X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback"); } } } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/blogs/error.jsp"; } else { throw new PortletException(e); } } return "/blogs/view_entry.jsp"; }
From source file:com.liferay.bookmarks.web.internal.portlet.action.BookmarksAdminConfigurationAction.java
License:Open Source License
protected void validateRootFolder(ActionRequest actionRequest) throws Exception { long rootFolderId = GetterUtil.getLong(getParameter(actionRequest, "rootFolderId")); if (rootFolderId != BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) { try {//from w ww .ja va 2 s . co m _bookmarksFolderLocalService.getFolder(rootFolderId); } catch (NoSuchFolderException nsfe) { SessionErrors.add(actionRequest, "rootFolderIdInvalid"); } } }
From source file:com.liferay.bookmarks.web.internal.portlet.action.EditEntryMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/* w ww. j av a 2s . c o m*/ BookmarksEntry entry = null; if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { entry = updateEntry(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteEntry(actionRequest, false); } else if (cmd.equals(Constants.MOVE)) { moveEntries(actionRequest); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteEntry(actionRequest, true); } else if (cmd.equals(Constants.RESTORE)) { restoreTrashEntries(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribeEntry(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribeEntry(actionRequest); } WindowState windowState = actionRequest.getWindowState(); if (windowState.equals(LiferayWindowState.POP_UP)) { String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { if (cmd.equals(Constants.ADD) && (entry != null)) { String portletId = HttpUtil.getParameter(redirect, "p_p_id", false); String namespace = PortalUtil.getPortletNamespace(portletId); redirect = HttpUtil.addParameter(redirect, namespace + "className", BookmarksEntry.class.getName()); redirect = HttpUtil.addParameter(redirect, namespace + "classPK", entry.getEntryId()); } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); } } } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/bookmarks/error.jsp"); } else if (e instanceof EntryURLException || e instanceof NoSuchFolderException) { SessionErrors.add(actionRequest, e.getClass()); } else if (e instanceof AssetCategoryException || e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { throw e; } } }
From source file:com.liferay.bookmarks.web.internal.portlet.action.EditFolderMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/* www .j a va2s . c o m*/ if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateFolder(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteFolders(actionRequest, false); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteFolders(actionRequest, true); } else if (cmd.equals(Constants.RESTORE)) { restoreTrashEntries(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribeFolder(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribeFolder(actionRequest); } } catch (Exception e) { if (e instanceof NoSuchFolderException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/bookmarks/error.jsp"); } else if (e instanceof FolderNameException) { SessionErrors.add(actionRequest, e.getClass()); } else { throw e; } } }
From source file:com.liferay.bookmarks.web.internal.portlet.action.GetEntryMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {/*from w w w. j a v a2 s.c o m*/ BookmarksEntry entry = ActionUtil.getEntry(renderRequest); renderRequest.setAttribute(BookmarksWebKeys.BOOKMARKS_ENTRY, entry); } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/bookmarks/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
From source file:com.liferay.bookmarks.web.internal.portlet.action.GetFolderMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {/* w w w .j a va2 s . c o m*/ BookmarksFolder folder = ActionUtil.getFolder(renderRequest); renderRequest.setAttribute(BookmarksWebKeys.BOOKMARKS_FOLDER, folder); } catch (Exception e) { if (e instanceof NoSuchFolderException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/bookmarks/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
From source file:com.liferay.bookmarks.web.internal.portlet.action.MoveEntryMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {/*from w ww. j a v a 2s .c om*/ List<BookmarksEntry> entries = ActionUtil.getEntries(renderRequest); renderRequest.setAttribute(BookmarksWebKeys.BOOKMARKS_ENTRIES, entries); BookmarksEntry entry = ActionUtil.getEntry(renderRequest); renderRequest.setAttribute(BookmarksWebKeys.BOOKMARKS_ENTRY, entry); List<BookmarksFolder> folders = ActionUtil.getFolders(renderRequest); renderRequest.setAttribute(BookmarksWebKeys.BOOKMARKS_FOLDERS, folders); } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/bookmarks/error.jsp"; } else { throw new PortletException(e); } } return "/bookmarks/move_entries.jsp"; }
From source file:com.liferay.bookmarks.web.internal.portlet.action.ViewMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {//from w w w. j a va 2 s . co m BookmarksFolder folder = ActionUtil.getFolder(renderRequest); renderRequest.setAttribute(BookmarksWebKeys.BOOKMARKS_FOLDER, folder); renderRequest.setAttribute(BookmarksWebKeys.BOOKMARKS_PORTLET_TOOLBAR_CONTRIBUTOR, _bookmarksPortletToolbarContributor); } catch (Exception e) { if (e instanceof NoSuchFolderException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/bookmarks/error.jsp"; } else { throw new PortletException(e); } } return "/bookmarks/view.jsp"; }
From source file:com.liferay.calendar.portlet.CalendarPortlet.java
License:Open Source License
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {//www . j a v a 2 s . co m getCalendar(renderRequest); getCalendarBooking(renderRequest); getCalendarResource(renderRequest); } catch (Exception e) { if (e instanceof NoSuchResourceException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); } else { throw new PortletException(e); } } super.render(renderRequest, renderResponse); }