List of usage examples for com.liferay.portal.kernel.servlet SessionErrors isEmpty
public static boolean isEmpty(PortletRequest portletRequest)
From source file:com.liferay.plugin.portlet.assetpublisher.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {//from w w w . j a v a 2s . com String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); if (cmd.equals("add-selection")) { PluginAssetPublisherUtil.addSelection(actionRequest, preferences); } else if (cmd.equals("move-selection-down")) { moveSelectionDown(actionRequest, preferences); } else if (cmd.equals("move-selection-up")) { moveSelectionUp(actionRequest, preferences); } else if (cmd.equals("remove-selection")) { removeSelection(actionRequest, preferences); } else if (cmd.equals("selection-style")) { setSelectionStyle(actionRequest, preferences); } else if (cmd.equals(Constants.UPDATE)) { String selectionStyle = preferences.getValue("selection-style", "dynamic"); if (selectionStyle.equals("dynamic")) { updateDynamicSettings(actionRequest, preferences); } else if (selectionStyle.equals("manual")) { updateManualSettings(actionRequest, preferences); } } if (SessionErrors.isEmpty(actionRequest)) { preferences.store(); SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure"); } String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } catch (Exception e) { if (e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass().getName(), e); } else { throw e; } } }
From source file:com.liferay.portlet.admin.action.EditServerAction.java
License:Open Source License
protected void updateCaptcha(ActionRequest actionRequest, PortletPreferences preferences) throws Exception { boolean reCaptchaEnabled = ParamUtil.getBoolean(actionRequest, "reCaptchaEnabled"); String reCaptchaPrivateKey = ParamUtil.getString(actionRequest, "reCaptchaPrivateKey"); String reCaptchaPublicKey = ParamUtil.getString(actionRequest, "reCaptchaPublicKey"); Captcha captcha = null;//from w w w . j ava2s.co m if (reCaptchaEnabled) { captcha = new ReCaptchaImpl(); } else { captcha = new SimpleCaptchaImpl(); } validateCaptcha(actionRequest); if (SessionErrors.isEmpty(actionRequest)) { preferences.setValue(PropsKeys.CAPTCHA_ENGINE_IMPL, captcha.getClass().getName()); preferences.setValue(PropsKeys.CAPTCHA_ENGINE_RECAPTCHA_KEY_PRIVATE, reCaptchaPrivateKey); preferences.setValue(PropsKeys.CAPTCHA_ENGINE_RECAPTCHA_KEY_PUBLIC, reCaptchaPublicKey); preferences.store(); CaptchaImpl captchaImpl = (CaptchaImpl) CaptchaUtil.getCaptcha(); captchaImpl.setCaptcha(captcha); } }
From source file:com.liferay.portlet.assetpublisher.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);//from w w w . j a va 2s. com if (cmd.equals(Constants.UPDATE)) { updateDisplaySettings(actionRequest); String selectionStyle = getParameter(actionRequest, "selectionStyle"); if (selectionStyle.equals("dynamic")) { updateQueryLogic(actionRequest, preferences); } updateDefaultAssetPublisher(actionRequest); super.processAction(portletConfig, actionRequest, actionResponse); } else { try { if (cmd.equals("add-selection")) { AssetPublisherUtil.addSelection(actionRequest, preferences); } else if (cmd.equals("move-selection-down")) { moveSelectionDown(actionRequest, preferences); } else if (cmd.equals("move-selection-up")) { moveSelectionUp(actionRequest, preferences); } else if (cmd.equals("remove-selection")) { removeSelection(actionRequest, preferences); } else if (cmd.equals("selection-style")) { setSelectionStyle(actionRequest, preferences); } if (SessionErrors.isEmpty(actionRequest)) { preferences.store(); SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); } String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } catch (Exception e) { if (e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass().getName(), e); } else { throw e; } } } }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void editPublicRenderParameters(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); Enumeration<String> enu = portletPreferences.getNames(); while (enu.hasMoreElements()) { String name = enu.nextElement(); if (name.startsWith(PublicRenderParameterConfiguration.IGNORE_PREFIX) || name.startsWith(PublicRenderParameterConfiguration.MAPPING_PREFIX)) { portletPreferences.reset(name); }/*from w w w.j a va2 s . c o m*/ } for (PublicRenderParameter publicRenderParameter : portlet.getPublicRenderParameters()) { String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(publicRenderParameter); boolean ignoreValue = ParamUtil.getBoolean(actionRequest, ignoreKey); if (ignoreValue) { portletPreferences.setValue(ignoreKey, String.valueOf(Boolean.TRUE)); } else { String mappingKey = PublicRenderParameterConfiguration.getMappingKey(publicRenderParameter); String mappingValue = ParamUtil.getString(actionRequest, mappingKey); if (Validator.isNotNull(mappingValue)) { portletPreferences.setValue(mappingKey, mappingValue); } } } if (SessionErrors.isEmpty(actionRequest)) { portletPreferences.store(); } }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void editScope(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); updateScope(actionRequest, portlet); if (!SessionErrors.isEmpty(actionRequest)) { return;//from w w w . j a v a 2 s . c o m } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void editSharing(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); updateAnyWebsite(actionRequest, portletPreferences); updateFacebook(actionRequest, portletPreferences); updateFriends(actionRequest, portletPreferences); updateGoogleGadget(actionRequest, portletPreferences); updateNetvibes(actionRequest, portletPreferences); portletPreferences.store();/*from www. ja va 2 s.c o m*/ if (!SessionErrors.isEmpty(actionRequest)) { return; } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); }
From source file:com.liferay.portlet.documentlibrary.action.EditFileEntryTypeAction.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 {/* ww w.j av a 2 s . c o m*/ if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateFileEntryType(actionRequest, actionResponse); } else if (cmd.equals(Constants.DELETE)) { deleteFileEntryType(actionRequest, actionResponse); } if (SessionErrors.isEmpty(actionRequest)) { SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, PortletKeys.DOCUMENT_LIBRARY); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof DuplicateFileEntryTypeException || e instanceof NoSuchMetadataSetException || e instanceof StructureDuplicateElementException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else if (e instanceof NoSuchFileEntryTypeException || e instanceof NoSuchStructureException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.document_library.error"); } else if (e instanceof RequiredStructureException) { SessionErrors.add(actionRequest, e.getClass().getName()); sendRedirect(actionRequest, actionResponse); } else { throw e; } } }
From source file:com.liferay.portlet.journalcontent.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String[] extensions = actionRequest.getParameterValues("extensions"); setPreference(actionRequest, "extensions", extensions); super.processAction(portletConfig, actionRequest, actionResponse); if (SessionErrors.isEmpty(actionRequest)) { updateContentSearch(actionRequest); }/*from ww w .ja va 2 s . c o m*/ }
From source file:com.liferay.portlet.portalsettings.action.EditCompanyAction.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 {/* w w w. j av a 2s .c om*/ if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { validateCAS(actionRequest); if (!SessionErrors.isEmpty(actionRequest)) { setForward(actionRequest, "portlet.portal_settings.edit_company"); } else { updateCompany(actionRequest); updateDisplay(actionRequest); sendRedirect(actionRequest, actionResponse); } } } catch (Exception e) { if (e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.portal_settings.error"); } else if (e instanceof AddressCityException || e instanceof AccountNameException || e instanceof AddressStreetException || e instanceof AddressZipException || e instanceof CompanyMxException || e instanceof CompanyVirtualHostException || e instanceof CompanyWebIdException || e instanceof EmailAddressException || e instanceof LocaleException || e instanceof NoSuchCountryException || e instanceof NoSuchListTypeException || e instanceof NoSuchRegionException || e instanceof PhoneNumberException || e instanceof WebsiteURLException) { if (e instanceof NoSuchListTypeException) { NoSuchListTypeException nslte = (NoSuchListTypeException) e; SessionErrors.add(actionRequest, e.getClass().getName() + nslte.getType()); } else { SessionErrors.add(actionRequest, e.getClass().getName(), e); } setForward(actionRequest, "portlet.portal_settings.edit_company"); } else { throw e; } } }
From source file:com.liferay.portlet.portletconfiguration.action.ActionUtil.java
License:Open Source License
public static void getPublicRenderParameterConfigurationList(PortletRequest portletRequest, Portlet portlet) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); PortletPreferences preferences = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portlet.getPortletId());/*from w ww.ja v a 2 s. c om*/ List<PublicRenderParameterConfiguration> publicRenderParameterConfigurations = new ArrayList<PublicRenderParameterConfiguration>(); for (PublicRenderParameter publicRenderParameter : portlet.getPublicRenderParameters()) { String mappingKey = PublicRenderParameterConfiguration.getMappingKey(publicRenderParameter); String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(publicRenderParameter); String mappingValue = null; boolean ignoreValue = false; if (SessionErrors.isEmpty(portletRequest)) { mappingValue = preferences.getValue(mappingKey, null); ignoreValue = GetterUtil.getBoolean(preferences.getValue(ignoreKey, null)); } else { mappingValue = ParamUtil.getString(portletRequest, mappingKey); ignoreValue = GetterUtil.getBoolean(ParamUtil.getString(portletRequest, ignoreKey)); } publicRenderParameterConfigurations .add(new PublicRenderParameterConfiguration(publicRenderParameter, mappingValue, ignoreValue)); } Collections.sort(publicRenderParameterConfigurations, new PublicRenderParameterIdentifierConfigurationComparator()); portletRequest.setAttribute(WebKeys.PUBLIC_RENDER_PARAMETER_CONFIGURATIONS, publicRenderParameterConfigurations); }