List of usage examples for com.liferay.portal.kernel.servlet SessionErrors add
public static void add(PortletRequest portletRequest, String key)
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerPortlet.java
License:Open Source License
@ProcessAction(name = "savePersonalizedTheme") public void saveAction(ActionRequest request, ActionResponse response) throws IOException { try {/*from www. j av a 2s .co m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String selectedThemeId = ParamUtil.getString(request, PARAM_SELECTED_THEME_ID); String selectedColorSchemeId = ParamUtil.getString(request, PARAM_SELECTED_COLOR_SCHEME_ID); boolean applyForAllPages = ParamUtil.getBoolean(request, PARAM_APPLY_FOR_ALL_PAGES); UserPersonalizedThemeLocalServiceUtil.addUserPersonalizedTheme(themeDisplay.getUserId(), themeDisplay.getLayout().getLayoutId(), selectedThemeId, selectedColorSchemeId, applyForAllPages); SessionMessages.add(request, "theme-personalization-changes-saved-scucessfully"); sendRedirect(request, response); } catch (SystemException e) { SessionErrors.add(request, "system-error-please-contact-adminstrator"); _log.error("Error persisting personalized theme information", e); } }
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerPortlet.java
License:Open Source License
@ProcessAction(name = "resetPersonalizedTheme") public void resetAction(ActionRequest request, ActionResponse response) throws IOException { try {/*from w w w .ja v a2 s .com*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); UserPersonalizedTheme userPersonalizedTheme = UserPersonalizedThemeLocalServiceUtil .findByUserIDAndLayoutId(themeDisplay.getCompanyId(), themeDisplay.getUserId(), themeDisplay.getLayout().getLayoutId()); UserPersonalizedThemeLocalServiceUtil.deleteUserPersonalizedTheme(userPersonalizedTheme); SessionMessages.add(request, "theme-personalization-restored-to-default"); sendRedirect(request, response); } catch (SystemException e) { SessionErrors.add(request, "system-error-please-contact-adminstrator"); _log.error("Error removing personalized theme information", e); } }
From source file:com.liferay.adaptive.media.web.internal.portlet.action.EditImageConfigurationEntryMVCActionCommand.java
License:Open Source License
@Override protected void doPermissionCheckedProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { hideDefaultErrorMessage(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String name = ParamUtil.getString(actionRequest, "name"); String description = ParamUtil.getString(actionRequest, "description"); String uuid = ParamUtil.getString(actionRequest, "uuid"); String maxHeight = ParamUtil.getString(actionRequest, "maxHeight"); String maxWidth = ParamUtil.getString(actionRequest, "maxWidth"); Map<String, String> properties = new HashMap<>(); properties.put("max-height", maxHeight); properties.put("max-width", maxWidth); Optional<AdaptiveMediaImageConfigurationEntry> configurationEntryOptional = _adaptiveMediaImageConfigurationHelper .getAdaptiveMediaImageConfigurationEntry(themeDisplay.getCompanyId(), uuid); boolean automaticUuid = ParamUtil.getBoolean(actionRequest, "automaticUuid"); String newUuid = null;/* www.ja v a 2 s . c o m*/ boolean autoModifiedUuid = false; if (automaticUuid) { String normalizedName = FriendlyURLNormalizerUtil.normalize(name); newUuid = _getAutomaticUuid(themeDisplay.getCompanyId(), normalizedName, uuid); if (!newUuid.equals(normalizedName)) { autoModifiedUuid = true; } } else { newUuid = ParamUtil.getString(actionRequest, "newUuid"); } try { if (configurationEntryOptional.isPresent()) { AdaptiveMediaImageConfigurationEntry configurationEntry = configurationEntryOptional.get(); if (!_isConfigurationEntryEditable(themeDisplay.getCompanyId(), configurationEntryOptional.get())) { newUuid = configurationEntry.getUUID(); properties = configurationEntry.getProperties(); autoModifiedUuid = false; } configurationEntry = _adaptiveMediaImageConfigurationHelper .updateAdaptiveMediaImageConfigurationEntry(themeDisplay.getCompanyId(), uuid, name, description, newUuid, properties); if (autoModifiedUuid) { SessionMessages.add(actionRequest, "configurationEntryUpdatedAndIDRenamed", configurationEntry); } else { SessionMessages.add(actionRequest, "configurationEntryUpdated", configurationEntry); } } else { AdaptiveMediaImageConfigurationEntry configurationEntry = _adaptiveMediaImageConfigurationHelper .addAdaptiveMediaImageConfigurationEntry(themeDisplay.getCompanyId(), name, description, newUuid, properties); boolean addHighResolution = ParamUtil.getBoolean(actionRequest, "addHighResolution"); AdaptiveMediaImageConfigurationEntry highResolutionConfigurationEntry = null; if (addHighResolution) { highResolutionConfigurationEntry = _addHighResolutionConfigurationEntry( themeDisplay.getCompanyId(), configurationEntry); SessionMessages.add(actionRequest, "highResolutionConfigurationEntryAdded", new AdaptiveMediaImageConfigurationEntry[] { configurationEntry, highResolutionConfigurationEntry }); } else { if (autoModifiedUuid) { SessionMessages.add(actionRequest, "configurationEntryAddedAndIDRenamed", configurationEntry); } else { SessionMessages.add(actionRequest, "configurationEntryAdded", configurationEntry); } } } } catch (AdaptiveMediaImageConfigurationException amice) { SessionErrors.add(actionRequest, amice.getClass()); } }
From source file:com.liferay.akismet.akismet.portlet.AkismetPortlet.java
License:Open Source License
public void updateConfiguration(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String apiKey = ParamUtil.getString(actionRequest, "apiKey"); int checkThreshold = ParamUtil.getInteger(actionRequest, "checkThreshold"); boolean discussionsEnabled = ParamUtil.getBoolean(actionRequest, "discussionsEnabled"); boolean messageBoardsEnabled = ParamUtil.getBoolean(actionRequest, "messageBoardsEnabled"); int reportableTime = ParamUtil.getInteger(actionRequest, "reportableTime"); boolean wikiEnabled = ParamUtil.getBoolean(actionRequest, "wikiEnabled"); PortletPreferences preferences = PrefsPortletPropsUtil.getPortletPreferences(themeDisplay.getCompanyId()); preferences.setValue(PortletPropsKeys.AKISMET_API_KEY, apiKey); preferences.setValue(PortletPropsKeys.AKISMET_CHECK_THRESHOLD, String.valueOf(checkThreshold)); preferences.setValue(PortletPropsKeys.AKISMET_DISCUSSIONS_CHECK_ENABLED, String.valueOf(discussionsEnabled)); preferences.setValue(PortletPropsKeys.AKISMET_MESSAGE_BOARDS_CHECK_ENABLED, String.valueOf(messageBoardsEnabled)); preferences.setValue(PortletPropsKeys.AKISMET_REPORTABLE_TIME, String.valueOf(reportableTime)); preferences.setValue(PortletPropsKeys.AKISMET_WIKI_CHECK_ENABLED, String.valueOf(wikiEnabled)); preferences.store();// w ww . j ava2 s.c o m if (!AkismetUtil.verifyApiKey(themeDisplay.getCompanyId(), apiKey)) { SessionErrors.add(actionRequest, "apiKeyError"); } }
From source file:com.liferay.akismet.hook.action.AkismetEditMessageAction.java
License:Open Source License
@Override public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (cmd.equals("updateStatus")) { try {/*w w w . ja v a 2 s. co m*/ updateStatus(actionRequest, actionResponse); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); actionResponse.sendRedirect(redirect); } catch (PrincipalException pe) { throw pe; } catch (Exception e) { SessionErrors.add(actionRequest, e.getClass()); } } else { originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse); } }
From source file:com.liferay.akismet.hook.action.AkismetEditPageAction.java
License:Open Source License
@Override public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (cmd.equals("updateSummary")) { try {//from w ww .j a v a 2 s .c o m updateSummary(actionRequest, actionResponse); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); actionResponse.sendRedirect(redirect); } catch (PrincipalException pe) { throw pe; } catch (Exception e) { SessionErrors.add(actionRequest, e.getClass()); } } else { originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse); } }
From source file:com.liferay.akismet.portlet.AkismetPortlet.java
License:Open Source License
public void updateConfiguration(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); boolean enabled = ParamUtil.getBoolean(actionRequest, "enabled"); String apiKey = ParamUtil.getString(actionRequest, "apiKey"); PortletPreferences preferences = PrefsPortletPropsUtil.getPortletPreferences(themeDisplay.getCompanyId()); preferences.setValue("enabled", String.valueOf(enabled)); preferences.setValue(PortletPropsKeys.AKISMET_API_KEY, apiKey); preferences.store();//from www . jav a 2 s . c om if (!AkismetUtil.verifyApiKey(themeDisplay.getCompanyId(), apiKey)) { SessionErrors.add(actionRequest, "apiKeyError"); } }
From source file:com.liferay.announcements.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 {//from www .j a v a2 s.c om if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateEntry(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteEntry(actionRequest); } } catch (EntryContentException | EntryDisplayDateException | EntryExpirationDateException | EntryTitleException | EntryURLException | NoSuchEntryException | PrincipalException e) { SessionErrors.add(actionRequest, e.getClass()); } }
From source file:com.liferay.announcements.web.internal.portlet.action.EditEntryMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {/*from ww w. java2 s . c om*/ AnnouncementsEntry entry = ActionUtil.getEntry(renderRequest); renderRequest.setAttribute(AnnouncementsWebKeys.ANNOUNCEMENTS_ENTRY, entry); } catch (NoSuchEntryException | PrincipalException e) { SessionErrors.add(renderRequest, e.getClass()); return "/announcements/error.jsp"; } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new PortletException(e); } return "/announcements/edit_entry.jsp"; }
From source file:com.liferay.blogs.web.internal.portlet.action.EditEntryMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {//from ww w. j a va2 s .c o m ActionUtil.getEntry(renderRequest); renderRequest.setAttribute(BlogsWebKeys.BLOGS_ITEM_SELECTOR_HELPER, _blogsItemSelectorHelper); } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/blogs/error.jsp"; } else { throw new PortletException(e); } } return "/blogs/edit_entry.jsp"; }