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.dynamic.data.mapping.form.web.internal.portlet.DDMFormPortlet.java
License:Open Source License
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {/*w w w.ja v a 2 s .c o m*/ setRenderRequestAttributes(renderRequest, renderResponse); DDMFormDisplayContext ddlFormPortletDisplayContext = (DDMFormDisplayContext) renderRequest .getAttribute(WebKeys.PORTLET_DISPLAY_CONTEXT); checkFormIsNotRestricted(renderRequest, renderResponse, ddlFormPortletDisplayContext); } catch (Exception e) { if (isSessionErrorException(e)) { if (_log.isWarnEnabled()) { _log.warn(e, e); } hideDefaultErrorMessage(renderRequest); SessionErrors.add(renderRequest, e.getClass()); } else { throw new PortletException(e); } } super.render(renderRequest, renderResponse); }
From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.DDMPortlet.java
License:Open Source License
@Override public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { try {// w ww . j a va 2 s. c o m super.processAction(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof NoSuchStructureException || e instanceof NoSuchTemplateException || e instanceof PortletPreferencesException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); include("/error.jsp", actionRequest, actionResponse); } else if (e instanceof DDMFormLayoutValidationException || e instanceof DDMFormValidationException || e instanceof LocaleException || e instanceof MustNotDuplicateFieldName || e instanceof MustSetOptionsForField || e instanceof MustSetValidCharactersForFieldName || e instanceof RequiredStructureException || e instanceof RequiredTemplateException || e instanceof StructureDefinitionException || e instanceof StructureDuplicateElementException || e instanceof StructureNameException || e instanceof TemplateNameException || e instanceof TemplateNameException || e instanceof TemplateScriptException || e instanceof TemplateSmallImageNameException || e instanceof TemplateSmallImageSizeException) { SessionErrors.add(actionRequest, e.getClass(), e); if (e instanceof RequiredStructureException || e instanceof RequiredTemplateException) { String redirect = portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } } else { throw e; } } }
From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.DDMPortlet.java
License:Open Source License
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {/*from w w w . ja v a 2 s.c o m*/ setDDMDisplayContextRequestAttribute(renderRequest); setDDMTemplateRequestAttribute(renderRequest); setDDMStructureRequestAttribute(renderRequest); } catch (NoSuchStructureException | NoSuchTemplateException e) { // Let this slide because the user can manually input a structure // or template key for a new model that does not yet exist if (_log.isDebugEnabled()) { _log.debug(e, e); } } catch (Exception e) { if (e instanceof PortletPreferencesException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); include("/error.jsp", renderRequest, renderResponse); } else { throw new PortletException(e); } } super.render(renderRequest, renderResponse); }
From source file:com.liferay.EditRecordAction.java
License:Open Source License
@Override public void processAction(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/*from ww w. j av a 2s .co m*/ if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateRecord(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteRecord(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertRecordVersion(actionRequest); } else if (cmd.equals(Constants.TRANSLATE)) { updateRecord(actionRequest); setForward(actionRequest, "portlet.dynamic_data_lists.update_translation_redirect"); } if (Validator.isNotNull(cmd) && !cmd.equals(Constants.TRANSLATE)) { sendRedirect(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof NoSuchRecordException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); setForward(actionRequest, "portlet.dynamic_data_lists.error"); } else if (e instanceof FileSizeException || e instanceof StorageFieldRequiredException) { SessionErrors.add(actionRequest, e.getClass()); } else { throw e; } } }
From source file:com.liferay.EditRecordAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {//from w w w . jav a 2 s. com ActionUtil.getRecord(renderRequest); } catch (Exception e) { if (e instanceof NoSuchRecordException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return actionMapping.findForward("portlet.dynamic_data_lists.error"); } else { throw e; } } return actionMapping.findForward(getForward(renderRequest, "portlet.dynamic_data_lists.edit_record")); }
From source file:com.liferay.events.global.mobile.portlet.ContactsPortlet.java
License:Open Source License
@ProcessAction(name = "updateEventContact") public void updateEventContact(ActionRequest request, ActionResponse response) throws SystemException, PortalException { long id = ParamUtil.getLong(request, "eventContactId"); try {//from ww w . j a v a 2s . c o m EventContact ec = EventContactLocalServiceUtil.getEventContact(id); ec.setGivenName(ParamUtil.getString(request, "givenName")); ec.setFullName(ParamUtil.getString(request, "fullName")); ec.setEmailAddress(ParamUtil.getString(request, "emailAddress")); ec.setCity(ParamUtil.getString(request, "city")); ec.setCountry(CountryServiceUtil.getCountryByA2(ParamUtil.getString(request, "country").toUpperCase()) .getA2()); ec.setJobTitle(ParamUtil.getString(request, "jobTitle")); ec.setCompany(ParamUtil.getString(request, "company")); ec.setIndustry(ParamUtil.getString(request, "industry")); ec.setAttendeeType(ParamUtil.getString(request, "attendeeType")); ec.setPicUrl(ParamUtil.getString(request, "picUrl")); ec.setIndustry(ParamUtil.getString(request, "industry")); ec.setEventId(ParamUtil.getString(request, "eventId")); ec.setInterests(JSONFactoryUtil.createJSONArray(ParamUtil.getString(request, "interests")).toString()); ec.setDesires(JSONFactoryUtil.createJSONArray(ParamUtil.getString(request, "desires")).toString()); ec.setExpertise(JSONFactoryUtil.createJSONArray(ParamUtil.getString(request, "expertise")).toString()); EventContactLocalServiceUtil.updateEventContact(ec); } catch (Exception ex) { SessionErrors.add(request, "Uh oh: " + ex); } }
From source file:com.liferay.events.global.mobile.portlet.PollsPortlet.java
License:Open Source License
@ProcessAction(name = "updateEventPollQuestion") public void updateEventPollQuestion(ActionRequest request, ActionResponse response) throws Exception { ServiceContext serviceContext = ServiceContextFactory.getInstance(EventPollQuestion.class.getName(), request);/*w w w. j ava2 s . c om*/ boolean enabled = ParamUtil.getBoolean(request, "enabled"); boolean autoEnable = ParamUtil.getBoolean(request, "autoEnable"); long questionId = ParamUtil.getLong(request, "questionId"); String eventId = ParamUtil.getString(request, "eventId"); String shortTitle = ParamUtil.getString(request, "shortTitle"); String sponsorName = ParamUtil.getString(request, "sponsorName"); String question = ParamUtil.getString(request, "question"); String questionType = ParamUtil.getString(request, "questionType"); String chartType = ParamUtil.getString(request, "chartType"); boolean anonymousResults = ParamUtil.getBoolean(request, "anonymousResults"); boolean showResponseCount = ParamUtil.getBoolean(request, "showResponseCount"); boolean askForId = ParamUtil.getBoolean(request, "askForId"); String choices = ParamUtil.getString(request, "choices"); String idIntro = ParamUtil.getString(request, "idIntro"); String picUrl = ParamUtil.getString(request, "picUrl"); String dateStr = ParamUtil.getString(request, "datePicker"); String timeStr = ParamUtil.getString(request, "timePicker"); String[] parts = dateStr.split("[^0-9]"); int year = Integer.parseInt(parts[0]); int month = Integer.parseInt(parts[1]); int day = Integer.parseInt(parts[2]); parts = timeStr.split("[^0-9]"); int hour = Integer.parseInt(parts[0]); int minute = Integer.parseInt(parts[1]); String tz = ParamUtil.getString(request, "tz"); Calendar c = Calendar.getInstance(TimeZone.getTimeZone(tz)); c.set(Calendar.DAY_OF_MONTH, day); c.set(Calendar.MONTH, month - 1); c.set(Calendar.YEAR, year); c.set(Calendar.HOUR_OF_DAY, hour); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, 0); if (questionId > 0) { try { EventPollQuestionLocalServiceUtil.updateQuestion(questionId, enabled, autoEnable, c.getTime(), tz, eventId, sponsorName, shortTitle, question, chartType, askForId, idIntro, questionType, choices, anonymousResults, showResponseCount, picUrl, serviceContext); SessionMessages.add(request, "entryAdded"); response.setRenderParameter("questionId", Long.toString(questionId)); } catch (Exception e) { SessionErrors.add(request, e.getClass().getName()); PortalUtil.copyRequestParameters(request, response); response.setRenderParameter("mvcPath", "/html/polls/edit.jsp"); e.printStackTrace(); } } else { try { EventPollQuestionLocalServiceUtil.addQuestion(eventId, sponsorName, shortTitle, question, questionType, chartType, askForId, idIntro, choices, anonymousResults, showResponseCount, picUrl, enabled, autoEnable, c.getTime(), tz, serviceContext); SessionMessages.add(request, "entryAdded"); response.setRenderParameter("questionId", Long.toString(questionId)); } catch (Exception e) { SessionErrors.add(request, e.getClass().getName()); PortalUtil.copyRequestParameters(request, response); response.setRenderParameter("mvcPath", "/html/polls/edit.jsp"); e.printStackTrace(); } } }
From source file:com.liferay.events.global.mobile.portlet.PollsPortlet.java
License:Open Source License
@ProcessAction(name = "addAnswer") public void addAnswer(ActionRequest request, ActionResponse response) throws Exception { ServiceContext serviceContext = ServiceContextFactory.getInstance(EventPollQuestion.class.getName(), request);//from w w w. j a va2s . c om long questionId = ParamUtil.getLong(request, "questionId"); String answer = ParamUtil.getString(request, "answer"); String clientId = ParamUtil.getString(request, "clientId"); String payload = ParamUtil.getString(request, "payload"); try { EventPollAnswerLocalServiceUtil.addAnswer(questionId, clientId, payload, answer, serviceContext); SessionMessages.add(request, "entryAdded"); response.setRenderParameter("questionId", Long.toString(questionId)); } catch (Exception e) { SessionErrors.add(request, e.getClass().getName()); PortalUtil.copyRequestParameters(request, response); response.setRenderParameter("mvcPath", "/html/polls/edit.jsp"); e.printStackTrace(); } }
From source file:com.liferay.exportimport.web.internal.portlet.action.DeleteLayoutExportBackgroundTaskMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/*from www. ja v a 2s.c om*/ long[] backgroundTaskIds = ParamUtil.getLongValues(actionRequest, "deleteBackgroundTaskIds"); for (long backgroundTaskId : backgroundTaskIds) { _backgroundTaskManager.deleteBackgroundTask(backgroundTaskId); } } catch (Exception e) { if (e instanceof NoSuchBackgroundTaskException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/error.jsp"); } else { throw e; } } }
From source file:com.liferay.exportimport.web.internal.portlet.action.DeletePortletBackgroundTaskMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/*from ww w .ja va2 s. co m*/ ActionUtil.deleteBackgroundTask(actionRequest); } catch (Exception e) { if (e instanceof NoSuchBackgroundTaskException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/error.jsp"); } else { throw e; } } }