Example usage for com.liferay.portal.kernel.servlet SessionErrors add

List of usage examples for com.liferay.portal.kernel.servlet SessionErrors add

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet SessionErrors add.

Prototype

public static void add(PortletRequest portletRequest, String key) 

Source Link

Usage

From source file:com.liferay.portlet.dynamicdatamapping.action.EditTemplateAction.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 a2  s.c  o  m
        ActionUtil.getStructure(renderRequest);
        ActionUtil.getTemplate(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchTemplateException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass().getName());

            return mapping.findForward("portlet.dynamic_data_mapping.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.dynamic_data_mapping.edit_template"));
}

From source file:com.liferay.portlet.enterpriseadmin.action.EditOrganizationAction.java

License:Open Source License

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 .  j  ava 2  s .c om*/
        Organization organization = null;

        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            organization = updateOrganization(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteOrganizations(actionRequest);
        }

        String redirect = ParamUtil.getString(actionRequest, "redirect");

        if (organization != null) {
            redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "organizationId",
                    organization.getOrganizationId());
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        if (e instanceof NoSuchOrganizationException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.enterprise_admin.error");
        } else if (e instanceof AddressCityException || e instanceof AddressStreetException
                || e instanceof AddressZipException || e instanceof DuplicateOrganizationException
                || e instanceof EmailAddressException || e instanceof NoSuchCountryException
                || e instanceof NoSuchListTypeException || e instanceof NoSuchRegionException
                || e instanceof OrganizationNameException || e instanceof OrganizationParentException
                || e instanceof PhoneNumberException || e instanceof RequiredOrganizationException
                || 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());
            }

            if (e instanceof RequiredOrganizationException) {
                actionResponse.sendRedirect(ParamUtil.getString(actionRequest, "redirect"));
            }
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.enterpriseadmin.action.EditOrganizationAction.java

License:Open Source License

public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    try {//w  w w  .  java  2 s.  c  om
        ActionUtil.getOrganization(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchOrganizationException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass().getName());

            return mapping.findForward("portlet.enterprise_admin.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.enterprise_admin.edit_organization"));
}

From source file:com.liferay.portlet.expando.action.EditExpandoAction.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 ww .j  ava  2s . c  o  m*/
        if (cmd.equals(Constants.ADD)) {
            addExpando(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteExpando(actionRequest);
        } else if (cmd.equals(Constants.UPDATE)) {
            updateExpando(actionRequest);
        }

        sendRedirect(actionRequest, actionResponse);
    } catch (Exception e) {
        if (e instanceof NoSuchColumnException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.expando.error");
        } else if (e instanceof ColumnNameException || e instanceof ColumnTypeException
                || e instanceof DuplicateColumnNameException || e instanceof ValueDataException) {

            SessionErrors.add(actionRequest, e.getClass().getName());
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.expando.action.EditExpandoAction.java

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    try {//from   w w  w  .  ja  v a2  s  .co m
        ActionUtil.getColumn(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchColumnException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass().getName());

            return mapping.findForward("portlet.expando.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.expando.edit_expando"));
}

From source file:com.liferay.portlet.imagegallery.action.EditImageAction.java

License:Open Source License

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  a  v a 2 s . c  om*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateImage(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteImage(actionRequest);
        }

        sendRedirect(actionRequest, actionResponse);
    } catch (Exception e) {
        if (e instanceof NoSuchImageException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.image_gallery.error");
        } else if (e instanceof DuplicateImageNameException || e instanceof ImageNameException
                || e instanceof ImageSizeException || e instanceof NoSuchFolderException) {

            SessionErrors.add(actionRequest, e.getClass().getName());
        } else if (e instanceof TagsEntryException) {
            SessionErrors.add(actionRequest, e.getClass().getName(), e);
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.imagegallery.action.EditImageAction.java

License:Open Source License

public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    try {/*from  www .j  a  v a  2  s.  c o m*/
        ActionUtil.getImage(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchImageException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass().getName());

            return mapping.findForward("portlet.image_gallery.error");
        } else {
            throw e;
        }
    }

    String forward = "portlet.image_gallery.edit_image";

    return mapping.findForward(getForward(renderRequest, forward));
}

From source file:com.liferay.portlet.imagegallerydisplay.action.ViewAction.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  . jav  a  2  s .  com*/
        ActionUtil.getFolder(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchFolderException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass().getName());

            return mapping.findForward("portlet.image_gallery_display.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward("portlet.image_gallery_display.view");
}

From source file:com.liferay.portlet.imagegallerydisplay.action.ViewSlideShowAction.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. j  a va  2 s  .  c  o m
        ActionUtil.getFolder(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchFolderException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass().getName());

            return mapping.findForward("portlet.image_gallery_display.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward("portlet.image_gallery_display.view_slide_show");
}

From source file:com.liferay.portlet.invitation.action.ConfigurationActionImpl.java

License:Open Source License

protected void validateEmailMessage(ActionRequest actionRequest) {
    String emailMessageSubject = getParameter(actionRequest, "emailMessageSubject");
    String emailMessageBody = getParameter(actionRequest, "emailMessageBody");

    if (Validator.isNull(emailMessageSubject)) {
        SessionErrors.add(actionRequest, "emailMessageSubject");
    } else if (Validator.isNull(emailMessageBody)) {
        SessionErrors.add(actionRequest, "emailMessageBody");
    }// w  w w . ja  va  2s .c  om
}