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.layoutsadmin.action.EditLayoutsAction.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 . j ava 2s. co m*/ checkPermissions(renderRequest); } catch (PrincipalException pe) { SessionErrors.add(renderRequest, PrincipalException.class.getName()); return mapping.findForward("portlet.layouts_admin.error"); } try { getGroup(renderRequest); } catch (Exception e) { if (e instanceof NoSuchGroupException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return mapping.findForward("portlet.layouts_admin.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.layouts_admin.edit_layouts")); }
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutSetAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/*from w w w . j a v a 2 s . c o m*/ checkPermissions(actionRequest); } catch (PrincipalException pe) { return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try { if (cmd.equals(Constants.UPDATE)) { updateLayoutSet(actionRequest, actionResponse); } String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect"); if (Validator.isNotNull(closeRedirect)) { SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof PrincipalException || e instanceof SystemException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.layouts_admin.error"); } else if (e instanceof FileSizeException || e instanceof ImageTypeException || e instanceof UploadException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { throw e; } } }
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutSetAction.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 a va2s. c o m*/ checkPermissions(renderRequest); } catch (PrincipalException pe) { SessionErrors.add(renderRequest, PrincipalException.class.getName()); return mapping.findForward("portlet.layouts_admin.error"); } try { getGroup(renderRequest); } catch (Exception e) { if (e instanceof NoSuchGroupException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.layouts_admin.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.layouts_admin.edit_layouts")); }
From source file:com.liferay.portlet.layoutsadmin.action.ExportLayoutsAction.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. ja v a 2 s. c om ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId"); boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout"); long[] layoutIds = ParamUtil.getLongValues(actionRequest, "layoutIds"); String fileName = ParamUtil.getString(actionRequest, "exportFileName"); String range = ParamUtil.getString(actionRequest, "range"); Date startDate = null; Date endDate = null; if (range.equals("dateRange")) { int startDateMonth = ParamUtil.getInteger(actionRequest, "startDateMonth"); int startDateDay = ParamUtil.getInteger(actionRequest, "startDateDay"); int startDateYear = ParamUtil.getInteger(actionRequest, "startDateYear"); int startDateHour = ParamUtil.getInteger(actionRequest, "startDateHour"); int startDateMinute = ParamUtil.getInteger(actionRequest, "startDateMinute"); int startDateAmPm = ParamUtil.getInteger(actionRequest, "startDateAmPm"); if (startDateAmPm == Calendar.PM) { startDateHour += 12; } startDate = PortalUtil.getDate(startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, themeDisplay.getTimeZone(), new PortalException()); int endDateMonth = ParamUtil.getInteger(actionRequest, "endDateMonth"); int endDateDay = ParamUtil.getInteger(actionRequest, "endDateDay"); int endDateYear = ParamUtil.getInteger(actionRequest, "endDateYear"); int endDateHour = ParamUtil.getInteger(actionRequest, "endDateHour"); int endDateMinute = ParamUtil.getInteger(actionRequest, "endDateMinute"); int endDateAmPm = ParamUtil.getInteger(actionRequest, "endDateAmPm"); if (endDateAmPm == Calendar.PM) { endDateHour += 12; } endDate = PortalUtil.getDate(endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute, themeDisplay.getTimeZone(), new PortalException()); } else if (range.equals("fromLastPublishDate")) { LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, privateLayout); UnicodeProperties settingsProperties = layoutSet.getSettingsProperties(); long lastPublishDate = GetterUtil.getLong(settingsProperties.getProperty("last-publish-date")); if (lastPublishDate > 0) { Calendar cal = Calendar.getInstance(themeDisplay.getTimeZone(), themeDisplay.getLocale()); endDate = cal.getTime(); cal.setTimeInMillis(lastPublishDate); startDate = cal.getTime(); } } else if (range.equals("last")) { int rangeLast = ParamUtil.getInteger(actionRequest, "last"); Date now = new Date(); startDate = new Date(now.getTime() - (rangeLast * Time.HOUR)); endDate = now; } File file = LayoutServiceUtil.exportLayoutsAsFile(groupId, privateLayout, layoutIds, actionRequest.getParameterMap(), startDate, endDate); HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); ServletResponseUtil.sendFile(request, response, fileName, new FileInputStream(file), ContentTypes.APPLICATION_ZIP); FileUtil.delete(file); setForward(actionRequest, ActionConstants.COMMON_NULL); } catch (Exception e) { _log.error(e, e); SessionErrors.add(actionRequest, e.getClass().getName()); String pagesRedirect = ParamUtil.getString(actionRequest, "pagesRedirect"); sendRedirect(actionRequest, actionResponse, pagesRedirect); } }
From source file:com.liferay.portlet.layoutsadmin.action.ExportLayoutsAction.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 a v a 2s. c o m*/ ActionUtil.getGroup(renderRequest); } catch (Exception e) { if (e instanceof NoSuchGroupException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.layouts_admin.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.layouts_admin.export_layouts")); }
From source file:com.liferay.portlet.layoutsadmin.action.PublishLayoutsAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {/*w w w .ja va2 s . c om*/ ActionUtil.getGroup(renderRequest); } catch (Exception e) { if (e instanceof NoSuchGroupException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.layouts_admin.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.layouts_admin.publish_layouts")); }
From source file:com.liferay.portlet.layoutsetprototypes.action.EditLayoutSetPrototypeAction.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. ja v a2s. c o m if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateLayoutSetPrototype(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteLayoutSetPrototypes(actionRequest); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.layout_set_prototypes.error"); } else if (e instanceof RequiredLayoutSetPrototypeException) { SessionErrors.add(actionRequest, e.getClass().getName()); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } else { throw e; } } }
From source file:com.liferay.portlet.layoutsetprototypes.action.EditLayoutSetPrototypeAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {// ww w . j ava 2 s .co m ActionUtil.getLayoutSetPrototype(renderRequest); } catch (Exception e) { if (e instanceof NoSuchLayoutSetPrototypeException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.layout_set_prototypes.error"); } else { throw e; } } return mapping .findForward(getForward(renderRequest, "portlet.layout_set_prototypes.edit_layout_set_prototype")); }
From source file:com.liferay.portlet.login.action.CreateAnonymousAccountAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return;/* ww w . j av a2 s . c o m*/ } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setWindowState(LiferayWindowState.POP_UP); portletURL.setParameter("struts_action", "/login/login_redirect"); portletURL.setParameter("emailAddress", emailAddress); portletURL.setParameter("anonymousUser", Boolean.TRUE.toString()); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { if (cmd.equals(Constants.ADD)) { addAnonymousUser(actionRequest, actionResponse); sendRedirect(actionRequest, actionResponse, portletURL.toString()); } else if (cmd.equals(Constants.UPDATE)) { jsonObject = updateIncompleteUser(actionRequest, actionResponse); writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof DuplicateUserEmailAddressException) { User user = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { sendRedirect(actionRequest, actionResponse, portletURL.toString()); } } else if (e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactFirstNameException || e instanceof ContactFullNameException || e instanceof ContactLastNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof ReservedUserEmailAddressException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass().getName(), e); } else { _log.error("Unable to create anonymous account", e); PortalUtil.sendError(e, actionRequest, actionResponse); } } }
From source file:com.liferay.portlet.login.action.ForgotPasswordAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/* w w w .ja v a 2s .co m*/ if (PropsValues.USERS_REMINDER_QUERIES_ENABLED) { checkReminderQueries(actionRequest, actionResponse); } else { checkCaptcha(actionRequest); sendPassword(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof CaptchaTextException || e instanceof NoSuchUserException || e instanceof RequiredReminderQueryException || e instanceof SendPasswordException || e instanceof UserActiveException || e instanceof UserEmailAddressException || e instanceof UserReminderQueryException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { PortalUtil.sendError(e, actionRequest, actionResponse); } } }