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.knowledgebase.section.action.ConfigurationActionImpl.java
License:Open Source License
protected void updateGeneral(ActionRequest actionRequest) { String[] kbArticlesSections = actionRequest.getParameterValues("kbArticlesSections"); if (ArrayUtil.isEmpty(kbArticlesSections)) { SessionErrors.add(actionRequest, "kbArticlesSections"); }//from w w w . ja v a 2 s . com if (SessionErrors.isEmpty(actionRequest)) { setPreference(actionRequest, "kbArticlesSections", kbArticlesSections); } }
From source file:com.liferay.layout.admin.web.internal.portlet.action.EditLayoutMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try {//from w w w . java2 s . c om long selPlid = ParamUtil.getLong(renderRequest, "selPlid"); _layoutLocalService.getLayout(selPlid); } catch (Exception e) { if (e instanceof NoSuchLayoutException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/error.jsp"; } else { throw new PortletException(e); } } return "/edit_layout.jsp"; }
From source file:com.liferay.layout.admin.web.internal.portlet.action.ResetMergeFailCountAndMergeMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long layoutPrototypeId = ParamUtil.getLong(actionRequest, "layoutPrototypeId"); LayoutPrototype layoutPrototype = _layoutPrototypeLocalService.getLayoutPrototype(layoutPrototypeId); SitesUtil.setMergeFailCount(layoutPrototype, 0); long selPlid = ParamUtil.getLong(actionRequest, "selPlid"); Layout selLayout = _layoutLocalService.getLayout(selPlid); SitesUtil.resetPrototype(selLayout); SitesUtil.mergeLayoutPrototypeLayout(selLayout.getGroup(), selLayout); layoutPrototype = _layoutPrototypeService.getLayoutPrototype(layoutPrototypeId); int mergeFailCountAfterMerge = SitesUtil.getMergeFailCount(layoutPrototype); if (mergeFailCountAfterMerge > 0) { SessionErrors.add(actionRequest, "resetMergeFailCountAndMerge"); }/*from w w w . ja v a2 s. c om*/ }
From source file:com.liferay.layout.admin.web.internal.portlet.GroupPagesPortlet.java
License:Open Source License
@Override protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {//from www . j a va 2 s.c o m getGroup(renderRequest); } catch (Exception e) { if (e instanceof NoSuchGroupException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); } else { throw new PortletException(e); } } if (SessionErrors.contains(renderRequest, NoSuchGroupException.class.getName()) || SessionErrors.contains(renderRequest, PrincipalException.getNestedClasses())) { include("/error.jsp", renderRequest, renderResponse); } else { try { ServiceContext serviceContext = ServiceContextFactory.getInstance(renderRequest); ServiceContextThreadLocal.pushServiceContext(serviceContext); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e, e); } } renderRequest.setAttribute(LayoutAdminWebKeys.ASSET_DISPLAY_CONTRIBUTOR_TRACKER, _assetDisplayContributorTracker); renderRequest.setAttribute(ApplicationListWebKeys.GROUP_PROVIDER, _groupProvider); renderRequest.setAttribute(LayoutAdminWebKeys.ITEM_SELECTOR, _itemSelector); renderRequest.setAttribute(LayoutAdminWebKeys.LAYOUT_ADMIN_CONFIGURATION, _layoutAdminWebConfiguration); super.doDispatch(renderRequest, renderResponse); } }
From source file:com.liferay.linkshortener.portlet.AutoShortenerPortlet.java
License:Open Source License
public void shortenLinkAction(ActionRequest request, ActionResponse response) { String longLink = getAndValidateData(request); try {//from ww w .j a v a2 s . com if (longLink != null) { Link link = storeLongLink(longLink); String encodedLink = addHostName(link.getShortLink()); response.setRenderParameter(ENCODED_LINK_PARAM, encodedLink); } } catch (NestableException e) { SessionErrors.add(request, "auto-shortener-not-saved"); _LOG.error("Unable to store the new link.", e); } }
From source file:com.liferay.linkshortener.portlet.AutoShortenerPortlet.java
License:Open Source License
private String getAndValidateData(ActionRequest request) { String result = ParamUtil.getString(request, LINK_PARAM, StringPool.BLANK).trim(); if (result.equals(StringPool.BLANK)) { SessionErrors.add(request, "link-required"); }//from w w w.j ava 2 s. c o m return result; }
From source file:com.liferay.linkshortener.portlet.LinkTranslatorPortlet.java
License:Open Source License
public void addLink(ActionRequest request, ActionResponse response) { Link link = bindAndValidateObject(request); if (SessionErrors.isEmpty(request)) { try {// w w w. j a v a 2s . co m LinkServiceUtil.addLink(link); } catch (SystemException e) { SessionErrors.add(request, "link-translator-unable-to-add"); _LOG.error("Unable to add new entity.", e); } catch (ShortLinkTakenException e) { SessionErrors.add(request, "link-translator-link-taken"); _LOG.info("Short link is already taken."); } } }
From source file:com.liferay.linkshortener.portlet.LinkTranslatorPortlet.java
License:Open Source License
public void deleteLink(ActionRequest request, ActionResponse response) { long linkId = ParamUtil.getLong(request, LINK_ID_PARAM, 0); if (linkId != 0) { try {// w ww .ja v a 2s .com LinkServiceUtil.deleteLink(linkId); } catch (NestableException e) { SessionErrors.add(request, "link-translator-unable-to-delete"); _LOG.error("Unable to delete entry with ID " + linkId, e); } } else { SessionErrors.add(request, "link-translator-wrong-entry-id"); } }
From source file:com.liferay.linkshortener.portlet.LinkTranslatorPortlet.java
License:Open Source License
public void editLink(ActionRequest request, ActionResponse response) { Link link = bindAndValidateObject(request); if (SessionErrors.isEmpty(request)) { try {//from www. ja v a2s . com LinkServiceUtil.updateLink(link); } catch (SystemException e) { SessionErrors.add(request, "link-translator-unable-to-update"); _LOG.error("Unable to update link with Id " + link.getLinkId(), e); } catch (ShortLinkTakenException e) { SessionErrors.add(request, "link-translator-link-taken"); _LOG.info("Short link is already taken."); } } }
From source file:com.liferay.linkshortener.portlet.LinkValidator.java
License:Open Source License
public void validate(PortletRequest request, Link link) { String shortLink = link.getShortLink(); if ((shortLink == null) || shortLink.trim().equals(StringPool.BLANK)) { SessionErrors.add(request, "short-link-required"); } else if (shortLink.length() < ApplicationConstants.MIN_SHORT_URL) { SessionErrors.add(request, "short-link-to-short"); }/* ww w. ja v a 2 s. co m*/ String longLink = link.getLongLink(); if ((longLink == null) || longLink.trim().equals(StringPool.BLANK)) { SessionErrors.add(request, "long-link-required"); } }