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.portlet.journal.action.EditArticleAction.java
License:Open Source License
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {/*from w w w . j a v a 2s.c o m*/ String cmd = ParamUtil.getString(renderRequest, Constants.CMD); if (!cmd.equals(Constants.ADD)) { ActionUtil.getArticle(renderRequest); } } catch (NoSuchArticleException nsse) { // Let this slide because the user can manually input a article id // for a new article that does not yet exist. } catch (Exception e) { if (// e instanceof NoSuchArticleException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.journal.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.journal.edit_article")); }
From source file:com.liferay.portlet.journal.action.EditFeedAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {// ww w .j av a2 s . co m if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateFeed(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteFeeds(actionRequest); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof NoSuchFeedException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.journal.error"); } else if (e instanceof DuplicateFeedIdException || e instanceof FeedContentFieldException || e instanceof FeedIdException || e instanceof FeedNameException || e instanceof FeedTargetLayoutFriendlyUrlException || e instanceof FeedTargetPortletIdException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { throw e; } } }
From source file:com.liferay.portlet.journal.action.EditFeedAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {//from w ww .j a va2 s .c om String cmd = ParamUtil.getString(renderRequest, Constants.CMD); if (!cmd.equals(Constants.ADD)) { ActionUtil.getFeed(renderRequest); } } catch (NoSuchFeedException nssfe) { // Let this slide because the user can manually input a feed id for // a new syndicated feed that does not yet exist. } catch (Exception e) { if (e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.journal.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.journal.edit_feed")); }
From source file:com.liferay.portlet.journal.action.EditStructureAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); JournalStructure structure = null;//from w ww. jav a2 s .c o m try { if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { structure = updateStructure(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteStructures(actionRequest); } if (Validator.isNotNull(cmd)) { String redirect = ParamUtil.getString(actionRequest, "redirect"); if (structure != null) { boolean saveAndContinue = ParamUtil.getBoolean(actionRequest, "saveAndContinue"); if (saveAndContinue) { redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, structure, redirect); } } sendRedirect(actionRequest, actionResponse, redirect); } } catch (Exception e) { if (e instanceof NoSuchStructureException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.journal.error"); } else if (e instanceof DuplicateStructureElementException || e instanceof DuplicateStructureIdException || e instanceof RequiredStructureException || e instanceof StructureIdException || e instanceof StructureInheritanceException || e instanceof StructureNameException || e instanceof StructureXsdException) { SessionErrors.add(actionRequest, e.getClass().getName(), e); if (e instanceof RequiredStructureException) { String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } } else { throw e; } } }
From source file:com.liferay.portlet.journal.action.EditStructureAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {//w ww .j av a2 s .c om String cmd = ParamUtil.getString(renderRequest, Constants.CMD); if (!cmd.equals(Constants.ADD)) { ActionUtil.getStructure(renderRequest); } } catch (NoSuchStructureException nsse) { // Let this slide because the user can manually input a structure id // for a new structure that does not yet exist } catch (Exception e) { if (//e instanceof NoSuchStructureException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.journal.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.journal.edit_structure")); }
From source file:com.liferay.portlet.journal.action.EditTemplateAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); JournalTemplate template = null;/* ww w . j a va 2 s . c o m*/ try { if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { template = updateTemplate(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteTemplates(actionRequest); } String redirect = ParamUtil.getString(actionRequest, "redirect"); if (template != null) { boolean saveAndContinue = ParamUtil.getBoolean(actionRequest, "saveAndContinue"); if (saveAndContinue) { redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, template, redirect); } } sendRedirect(actionRequest, actionResponse, redirect); } catch (Exception e) { if (e instanceof NoSuchTemplateException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.journal.error"); } else if (e instanceof DuplicateTemplateIdException || e instanceof RequiredTemplateException || e instanceof TemplateIdException || e instanceof TemplateNameException || e instanceof TemplateSmallImageNameException || e instanceof TemplateSmallImageSizeException || e instanceof TemplateXslException) { SessionErrors.add(actionRequest, e.getClass().getName()); if (e instanceof RequiredTemplateException) { String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } } else { throw e; } } }
From source file:com.liferay.portlet.journal.action.EditTemplateAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {//from w w w .ja va 2 s. com String cmd = ParamUtil.getString(renderRequest, Constants.CMD); if (!cmd.equals(Constants.ADD)) { ActionUtil.getTemplate(renderRequest); } } catch (NoSuchTemplateException nsse) { // Let this slide because the user can manually input a template id // for a new template that does not yet exist. } catch (Exception e) { if (//e instanceof NoSuchTemplateException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.journal.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.journal.edit_template")); }
From source file:com.liferay.portlet.layoutprototypes.action.EditLayoutPrototypeAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/*from w w w . j av a 2s. co m*/ if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateLayoutPrototype(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteLayoutPrototypes(actionRequest); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.layout_prototypes.error"); } else { throw e; } } }
From source file:com.liferay.portlet.layoutprototypes.action.EditLayoutPrototypeAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {//from w ww .j ava 2 s .co m ActionUtil.getLayoutPrototype(renderRequest); } catch (Exception e) { if (e instanceof NoSuchLayoutPrototypeException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.layout_prototypes.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.layout_prototypes.edit_layout_prototype")); }
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutsAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/*from ww w.j ava 2 s . c om*/ checkPermissions(actionRequest); } catch (PrincipalException pe) { return; } ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); //Modification start SessionErrorsUtil.clear(actionRequest); SessionErrors.clear(actionRequest); //Modification end try { String redirect = ParamUtil.getString(actionRequest, "redirect"); String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect"); Layout layout = null; String oldFriendlyURL = StringPool.BLANK; if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { Object[] returnValue = updateLayout(actionRequest, actionResponse); layout = (Layout) returnValue[0]; oldFriendlyURL = (String) returnValue[1]; redirect = updateCloseRedirect(redirect, null, layout, oldFriendlyURL); closeRedirect = updateCloseRedirect(closeRedirect, null, layout, oldFriendlyURL); } else if (cmd.equals(Constants.DELETE)) { Object[] returnValue = SitesUtil.deleteLayout(actionRequest, actionResponse); Group group = (Group) returnValue[0]; oldFriendlyURL = (String) returnValue[1]; long newRefererPlid = (Long) returnValue[2]; redirect = updateCloseRedirect(redirect, group, null, oldFriendlyURL); redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid); // ===================== start of change https://jira.playtech.corp/browse/WPL-2040 redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "selPlid", newRefererPlid); // ===================== end of change closeRedirect = updateCloseRedirect(closeRedirect, group, null, oldFriendlyURL); } else if (cmd.equals("copy_from_live")) { StagingUtil.copyFromLive(actionRequest); } else if (cmd.equals("display_order")) { updateDisplayOrder(actionRequest); } else if (cmd.equals("delete_layout_revision")) { deleteLayoutRevision(actionRequest); } else if (cmd.equals("enable")) { enableLayout(actionRequest); } else if (cmd.equals("publish_to_live")) { StagingUtil.publishToLive(actionRequest); } else if (cmd.equals("publish_to_remote")) { StagingUtil.publishToRemote(actionRequest); } else if (cmd.equals("reset_customized_view")) { LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); if ((layoutTypePortlet != null) && layoutTypePortlet.isCustomizable() && layoutTypePortlet.isCustomizedView()) { layoutTypePortlet.resetUserPreferences(); } } else if (cmd.equals("reset_prototype")) { SitesUtil.resetPrototype(themeDisplay.getLayout()); } else if (cmd.equals("schedule_copy_from_live")) { StagingUtil.scheduleCopyFromLive(actionRequest); } else if (cmd.equals("schedule_publish_to_live")) { StagingUtil.schedulePublishToLive(actionRequest); } else if (cmd.equals("schedule_publish_to_remote")) { StagingUtil.schedulePublishToRemote(actionRequest); } else if (cmd.equals("select_layout_set_branch")) { selectLayoutSetBranch(actionRequest); } else if (cmd.equals("select_layout_branch")) { selectLayoutBranch(actionRequest); } else if (cmd.equals("unschedule_copy_from_live")) { StagingUtil.unscheduleCopyFromLive(actionRequest); } else if (cmd.equals("unschedule_publish_to_live")) { StagingUtil.unschedulePublishToLive(actionRequest); } else if (cmd.equals("unschedule_publish_to_remote")) { StagingUtil.unschedulePublishToRemote(actionRequest); } else if (cmd.equals("update_layout_revision")) { updateLayoutRevision(actionRequest, themeDisplay); } if (Validator.isNotNull(closeRedirect)) { LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig; SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect); } sendRedirect(actionRequest, actionResponse, redirect); } catch (Exception e) { if (e instanceof NoSuchLayoutException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); setForward(actionRequest, "portlet.layouts_admin.error"); } else if (e instanceof ImageTypeException || e instanceof LayoutFriendlyURLException || e instanceof LayoutHiddenException || e instanceof LayoutNameException || e instanceof LayoutParentLayoutIdException || e instanceof LayoutSetVirtualHostException || e instanceof LayoutTypeException || e instanceof RequiredLayoutException || e instanceof UploadException) { if (e instanceof LayoutFriendlyURLException) { SessionErrors.add(actionRequest, LayoutFriendlyURLException.class.getName(), e); } else { SessionErrors.add(actionRequest, e.getClass(), e); } } else if (e instanceof DuplicateLockException || e instanceof LayoutPrototypeException || e instanceof RemoteExportException || e instanceof RemoteOptionsException || e instanceof SystemException) { SessionErrors.add(actionRequest, e.getClass(), e); String redirect = ParamUtil.getString(actionRequest, "pagesRedirect"); sendRedirect(actionRequest, actionResponse, redirect); } else { throw e; } } finally { SessionErrorsUtil.copyFromSessionErrors(actionRequest); } }