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.documentlibrary.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  ww .  j  a  v a  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.document_library.error");
        } else {
            throw e;
        }
    }

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

From source file:com.liferay.portlet.dynamicdatalists.action.EditRecordAction.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   ww  w.  j  a v a2  s.com
        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);
        }

        if (Validator.isNotNull(cmd)) {
            sendRedirect(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchRecordException || e instanceof PrincipalException) {

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

            setForward(actionRequest, "portlet.dynamic_data_lists.error");
        } else if (e instanceof FileSizeException || e instanceof StorageFieldRequiredException) {

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

From source file:com.liferay.portlet.dynamicdatalists.action.EditRecordAction.java

License:Open Source License

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

    try {/*from   ww w .  ja v a  2 s .co m*/
        ActionUtil.getRecord(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchRecordException || e instanceof PrincipalException) {

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

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

    return mapping.findForward(getForward(renderRequest, "portlet.dynamic_data_lists.edit_record"));
}

From source file:com.liferay.portlet.dynamicdatalists.action.EditRecordSetAction.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) || cmd.equals(Constants.UPDATE)) {
            updateRecordSet(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteRecordSet(actionRequest);
        }

        if (Validator.isNotNull(cmd)) {
            sendRedirect(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchRecordSetException || e instanceof PrincipalException) {

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

            setForward(actionRequest, "portlet.dynamic_data_lists.error");
        } else if (e instanceof RecordSetDDMStructureIdException || e instanceof RecordSetNameException) {

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

From source file:com.liferay.portlet.dynamicdatalists.action.EditRecordSetAction.java

License:Open Source License

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

    try {//from w ww .  j a v a2  s . c om
        String cmd = ParamUtil.getString(renderRequest, Constants.CMD);

        if (!cmd.equals(Constants.ADD)) {
            ActionUtil.getRecordSet(renderRequest);
        }
    } catch (NoSuchRecordSetException nsee) {

        // Let this slide because the user can manually input an record set
        // key for a new record set that does not yet exist

    } catch (Exception e) {
        if (e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass().getName());

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

    return mapping.findForward(getForward(renderRequest, "portlet.dynamic_data_lists.edit_record_set"));
}

From source file:com.liferay.portlet.dynamicdatamapping.action.CopyStructureAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    try {/*  w w w  .j  a  v a2s .co m*/
        DDMStructure structure = copyStructure(actionRequest);

        String redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, structure);

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

        if (Validator.isNotNull(closeRedirect)) {
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect);
        }

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

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

            setForward(actionRequest, "portlet.dynamic_data_mapping.error");
        } else if (e instanceof StructureNameException) {
            SessionErrors.add(actionRequest, e.getClass().getName(), e);
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.dynamicdatamapping.action.CopyStructureAction.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 . j av  a  2 s . co m*/
        ActionUtil.getStructure(renderRequest);
    } catch (NoSuchStructureException nsse) {

        // Let this slide because the user can manually input a structure
        // key for a new structure that does not yet exist

    } catch (Exception e) {
        if (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.copy_structure"));
}

From source file:com.liferay.portlet.dynamicdatamapping.action.EditStructureAction.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);

    DDMStructure structure = null;//ww  w.j a  va 2 s .  co  m

    try {
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            structure = updateStructure(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteStructure(actionRequest);
        }

        if (Validator.isNotNull(cmd)) {
            String redirect = ParamUtil.getString(actionRequest, "redirect");

            if (structure != null) {
                boolean saveAndContinue = ParamUtil.getBoolean(actionRequest, "saveAndContinue");

                if (saveAndContinue) {
                    redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, structure, redirect);
                }
            }

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

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

            setForward(actionRequest, "portlet.dynamic_data_mapping.error");
        } else if (e instanceof RequiredStructureException || e instanceof StructureDuplicateElementException
                || e instanceof StructureNameException || e instanceof StructureXsdException) {

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

            if (e instanceof RequiredStructureException) {
                String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

                if (Validator.isNotNull(redirect)) {
                    actionResponse.sendRedirect(redirect);
                }
            }
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.dynamicdatamapping.action.EditStructureAction.java

License:Open Source License

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

    try {/*ww w  .jav  a  2s .c o  m*/
        String cmd = ParamUtil.getString(renderRequest, Constants.CMD);

        if (!cmd.equals(Constants.ADD)) {
            ActionUtil.getStructure(renderRequest);
        }
    } catch (NoSuchStructureException nsse) {

        // Let this slide because the user can manually input a structure
        // key for a new structure that does not yet exist

    } catch (Exception e) {
        if (//e instanceof NoSuchStructureException ||
        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_structure"));
}

From source file:com.liferay.portlet.dynamicdatamapping.action.EditTemplateAction.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);

    DDMTemplate template = null;//from   w  w w.  ja  v a 2 s .  c  o  m

    try {
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            template = updateTemplate(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteTemplate(actionRequest);
        }

        if (Validator.isNotNull(cmd)) {
            String redirect = ParamUtil.getString(actionRequest, "redirect");

            if (template != null) {
                boolean saveAndContinue = ParamUtil.getBoolean(actionRequest, "saveAndContinue");

                if (saveAndContinue) {
                    redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, template, redirect);
                }
            }

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

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

            setForward(actionRequest, "portlet.dynamic_data_mapping.error");
        } else if (e instanceof TemplateNameException || e instanceof TemplateScriptException) {

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