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.message.boards.web.internal.portlet.action.DeleteThreadMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/*from ww w .jav a2 s. co m*/ if (cmd.equals(Constants.DELETE)) { deleteThreads(actionRequest, false); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteThreads(actionRequest, true); } } catch (LockedThreadException | PrincipalException e) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp"); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.EditCategoryMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {//from ww w . jav a2 s. c om if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateCategory(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteCategories(actionRequest, false); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteCategories(actionRequest, true); } else if (cmd.equals(Constants.RESTORE)) { restoreTrashEntries(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribeCategory(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribeCategory(actionRequest); } } catch (NoSuchCategoryException | PrincipalException e) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp"); } catch (CaptchaConfigurationException | CaptchaTextException | CategoryNameException | MailingListEmailAddressException | MailingListInServerNameException | MailingListInUserNameException | MailingListOutEmailAddressException | MailingListOutServerNameException | MailingListOutUserNameException e) { SessionErrors.add(actionRequest, e.getClass()); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.EditCategoryMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {/* ww w . ja v a 2 s . c o m*/ MBCategory category = ActionUtil.getCategory(renderRequest); renderRequest.setAttribute(WebKeys.MESSAGE_BOARDS_CATEGORY, category); } catch (NoSuchCategoryException | PrincipalException e) { SessionErrors.add(renderRequest, e.getClass()); return "/message_boards/error.jsp"; } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new PortletException(e); } return "/message_boards/edit_category.jsp"; }
From source file:com.liferay.message.boards.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 {// ww w .j a va 2s . c o m if (cmd.equals(Constants.DELETE)) { deleteEntries(actionRequest, false); } else if (cmd.equals(Constants.LOCK)) { lockThreads(actionRequest); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteEntries(actionRequest, true); } else if (cmd.equals(Constants.UNLOCK)) { unlockThreads(actionRequest); } } catch (LockedThreadException | PrincipalException e) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp"); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.EditMessageAttachmentsMVCActionCommand.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 a v a 2s . c o m if (cmd.equals(Constants.CHECK)) { JSONObject jsonObject = RestoreEntryUtil.checkEntry(actionRequest); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); return; } else if (cmd.equals(Constants.DELETE)) { deleteAttachment(actionRequest); } else if (cmd.equals(Constants.EMPTY_TRASH)) { emptyTrash(actionRequest); } else if (cmd.equals(Constants.RENAME)) { restoreRename(actionRequest); } else if (cmd.equals(Constants.RESTORE)) { restoreEntries(actionRequest); } else if (cmd.equals(Constants.OVERRIDE)) { restoreOverride(actionRequest); } if (Validator.isNotNull(cmd)) { String redirect = ParamUtil.getString(actionRequest, "redirect"); sendRedirect(actionRequest, actionResponse, redirect); } } catch (PrincipalException pe) { SessionErrors.add(actionRequest, pe.getClass()); actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp"); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.EditMessageMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); MBMessage message = null;//from w ww .ja v a2 s . co m try { UploadException uploadException = (UploadException) actionRequest .getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { Throwable cause = uploadException.getCause(); if (uploadException.isExceededFileSizeLimit()) { throw new FileSizeException(cause); } if (uploadException.isExceededLiferayFileItemSizeLimit()) { throw new LiferayFileItemException(cause); } if (uploadException.isExceededUploadRequestSizeLimit()) { throw new UploadRequestSizeException(cause); } throw new PortalException(cause); } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { message = updateMessage(actionRequest, actionResponse); } else if (cmd.equals(Constants.ADD_ANSWER)) { addAnswer(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteMessage(actionRequest); } else if (cmd.equals(Constants.DELETE_ANSWER)) { deleteAnswer(actionRequest); } else if (cmd.equals(Constants.LOCK)) { lockThreads(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribeMessage(actionRequest); } else if (cmd.equals(Constants.UNLOCK)) { unlockThreads(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribeMessage(actionRequest); } if (Validator.isNotNull(cmd)) { WindowState windowState = actionRequest.getWindowState(); if (!windowState.equals(LiferayWindowState.POP_UP)) { String redirect = getRedirect(actionRequest, actionResponse, message); sendRedirect(actionRequest, actionResponse, redirect); } else { String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } } } catch (NoSuchMessageException | PrincipalException | RequiredMessageException e) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp"); } catch (AntivirusScannerException | CaptchaConfigurationException | CaptchaTextException | DuplicateFileEntryException | FileExtensionException | FileNameException | FileSizeException | LiferayFileItemException | LockedThreadException | MessageBodyException | MessageSubjectException | SanitizerException | UploadRequestSizeException e) { if (e instanceof AntivirusScannerException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { SessionErrors.add(actionRequest, e.getClass()); } } catch (AssetCategoryException | AssetTagException e) { SessionErrors.add(actionRequest, e.getClass(), e); } catch (Exception e) { Throwable cause = e.getCause(); if (cause instanceof SanitizerException) { SessionErrors.add(actionRequest, SanitizerException.class); } else { throw e; } } }
From source file:com.liferay.message.boards.web.internal.portlet.action.GetMessageMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {//from w ww . j a v a 2 s .c om MBMessage message = ActionUtil.getMessage(renderRequest); renderRequest.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE, message); } catch (NoSuchMessageException | PrincipalException e) { SessionErrors.add(renderRequest, e.getClass()); return "/message_boards/error.jsp"; } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new PortletException(e); } return getPath(); }
From source file:com.liferay.message.boards.web.internal.portlet.action.MBAdminConfigurationAction.java
License:Open Source License
protected void updateUserRanks(ActionRequest actionRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); for (Locale locale : LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId())) { String languageId = LocaleUtil.toLanguageId(locale); String[] ranks = StringUtil.splitLines(ParamUtil.getString(actionRequest, "ranks_" + languageId)); Map<String, String> map = new TreeMap<>(new NaturalOrderStringComparator()); for (String rank : ranks) { if (!isValidUserRank(rank)) { SessionErrors.add(actionRequest, "userRank"); return; }//from w ww . j a v a 2 s . c o m String[] kvp = StringUtil.split(rank, CharPool.EQUAL); String kvpName = kvp[0]; String kvpValue = kvp[1]; map.put(kvpValue, kvpName); } ranks = new String[map.size()]; int count = 0; for (Map.Entry<String, String> entry : map.entrySet()) { String kvpValue = entry.getKey(); String kvpName = entry.getValue(); ranks[count++] = kvpName + StringPool.EQUAL + kvpValue; } String preferenceName = LocalizationUtil.getLocalizedName("ranks", languageId); setPreference(actionRequest, preferenceName, ranks); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.MoveCategoryMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/* www .j a v a 2s . com*/ moveCategory(actionRequest, actionResponse); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } catch (PrincipalException pe) { SessionErrors.add(actionRequest, pe.getClass()); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.MoveCategoryMVCRenderAction.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {//from w w w. ja va 2s .c om MBCategory category = ActionUtil.getCategory(renderRequest); renderRequest.setAttribute(WebKeys.MESSAGE_BOARDS_CATEGORY, category); } catch (Exception e) { if (e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/message_boards/error.jsp"; } else { throw new PortletException(e); } } return "/message_boards/move_category.jsp"; }