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.usersadmin.action.ExportUsersAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/* ww w . j a v a 2 s . c o m*/ String csv = getUsersCSV(actionRequest, actionResponse); String fileName = "users.csv"; byte[] bytes = csv.getBytes(); HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); ServletResponseUtil.sendFile(request, response, fileName, bytes, ContentTypes.TEXT_CSV_UTF8); setForward(actionRequest, ActionConstants.COMMON_NULL); } catch (Exception e) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.users_admin.error"); } }
From source file:com.liferay.portlet.wiki.action.CompareVersionsAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {//from ww w . ja va2 s. c o m ActionUtil.getNode(renderRequest); ActionUtil.getPage(renderRequest); compareVersions(renderRequest, renderResponse); } catch (Exception e) { if (e instanceof NoSuchPageException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.wiki.error"); } else { throw e; } } return mapping.findForward("portlet.wiki.compare_versions"); }
From source file:com.liferay.portlet.wiki.action.ConfigurationActionImpl.java
License:Open Source License
protected void validateDisplaySettings(ActionRequest actionRequest) throws Exception { String visibleNodes = getParameter(actionRequest, "visibleNodes"); if (Validator.isNull(visibleNodes)) { SessionErrors.add(actionRequest, "visibleNodesCount"); }//www .j a va2 s .c om }
From source file:com.liferay.portlet.wiki.action.ConfigurationActionImpl.java
License:Open Source License
protected void validateEmailPageAdded(ActionRequest actionRequest) throws Exception { String emailPageAddedSubjectPrefix = getParameter(actionRequest, "emailPageAddedSubjectPrefix"); String emailPageAddedBody = getParameter(actionRequest, "emailPageAddedBody"); if (Validator.isNull(emailPageAddedSubjectPrefix)) { SessionErrors.add(actionRequest, "emailPageAddedSubjectPrefix"); } else if (Validator.isNull(emailPageAddedBody)) { SessionErrors.add(actionRequest, "emailPageAddedBody"); }//from ww w.ja va 2 s .com }
From source file:com.liferay.portlet.wiki.action.ConfigurationActionImpl.java
License:Open Source License
protected void validateEmailPageUpdated(ActionRequest actionRequest) throws Exception { String emailPageUpdatedSubjectPrefix = getParameter(actionRequest, "emailPageUpdatedSubjectPrefix"); String emailPageUpdatedBody = getParameter(actionRequest, "emailPageUpdatedBody"); if (Validator.isNull(emailPageUpdatedSubjectPrefix)) { SessionErrors.add(actionRequest, "emailPageUpdatedSubjectPrefix"); } else if (Validator.isNull(emailPageUpdatedBody)) { SessionErrors.add(actionRequest, "emailPageUpdatedBody"); }//ww w .j a va 2 s. c o m }
From source file:com.liferay.portlet.wiki.action.EditNodeAction.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 ww w . jav a 2 s .c o m if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateNode(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteNode(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribeNode(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribeNode(actionRequest); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof NoSuchNodeException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.wiki.error"); } else if (e instanceof DuplicateNodeNameException || e instanceof NodeNameException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { throw e; } } }
From source file:com.liferay.portlet.wiki.action.EditNodeAction.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 . java 2 s . c o m*/ long nodeId = ParamUtil.getLong(renderRequest, "nodeId"); if (nodeId > 0) { ActionUtil.getNode(renderRequest); } } catch (Exception e) { if (e instanceof NoSuchNodeException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.wiki.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.wiki.edit_node")); }
From source file:com.liferay.portlet.wiki.action.EditPageAction.java
License:Open Source License
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); WikiPage page = null;//from w ww. ja v a 2 s .c o m try { if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { page = updatePage(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deletePage(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertPage(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribePage(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribePage(actionRequest); } if (Validator.isNotNull(cmd)) { String redirect = ParamUtil.getString(actionRequest, "redirect"); if (page != null) { boolean saveAndContinue = ParamUtil.getBoolean(actionRequest, "saveAndContinue"); if (saveAndContinue) { redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, page, redirect); } else if (redirect.endsWith("title=")) { redirect += page.getTitle(); } } sendRedirect(actionRequest, actionResponse, redirect); } } catch (Exception e) { if (e instanceof NoSuchNodeException || e instanceof NoSuchPageException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.wiki.error"); } else if (e instanceof DuplicatePageException || e instanceof PageContentException || e instanceof PageVersionException || e instanceof PageTitleException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else if (e instanceof TagsEntryException) { SessionErrors.add(actionRequest, e.getClass().getName(), e); } else { throw e; } } }
From source file:com.liferay.portlet.wiki.action.EditPageAction.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 va 2 s . c o m ActionUtil.getNode(renderRequest); if (!SessionErrors.contains(renderRequest, DuplicatePageException.class.getName())) { getPage(renderRequest); } } catch (Exception e) { if (e instanceof NoSuchNodeException || e instanceof PageTitleException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.wiki.error"); } else if (e instanceof NoSuchPageException) { // Let edit_page.jsp handle this case } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.wiki.edit_page")); }
From source file:com.liferay.portlet.wiki.action.EditPageAttachmentAction.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 a va 2 s . c o m*/ if (Validator.isNull(cmd)) { UploadException uploadException = (UploadException) actionRequest .getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { if (uploadException.isExceededSizeLimit()) { throw new FileSizeException(uploadException.getCause()); } throw new PortalException(uploadException.getCause()); } } else if (cmd.equals(Constants.ADD)) { addAttachment(actionRequest); } else if (cmd.equals(Constants.ADD_MULTIPLE)) { addMultipleFileEntries(actionRequest, actionResponse); } else if (cmd.equals(Constants.ADD_TEMP)) { addTempAttachment(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteAttachment(actionRequest); } else if (cmd.equals(Constants.DELETE_TEMP)) { deleteTempAttachment(actionRequest, actionResponse); } if (cmd.equals(Constants.ADD_TEMP) || cmd.equals(Constants.DELETE_TEMP)) { setForward(actionRequest, ActionConstants.COMMON_NULL); } else { sendRedirect(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof DuplicateFileException || e instanceof NoSuchNodeException || e instanceof NoSuchPageException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.wiki.error"); } else if (e instanceof FileSizeException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { throw e; } } }