Example usage for com.liferay.portal.kernel.util Constants CHECK

List of usage examples for com.liferay.portal.kernel.util Constants CHECK

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Constants CHECK.

Prototype

String CHECK

To view the source code for com.liferay.portal.kernel.util Constants CHECK.

Click Source Link

Usage

From source file:com.liferay.message.boards.web.internal.portlet.action.EditMessageAttachmentsMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {//from  w ww.j av  a  2s. c om
        if (cmd.equals(Constants.CHECK)) {
            JSONObject jsonObject = RestoreEntryUtil.checkEntry(actionRequest);

            JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);

            return;
        } else if (cmd.equals(Constants.DELETE)) {
            deleteAttachment(actionRequest);
        } else if (cmd.equals(Constants.EMPTY_TRASH)) {
            emptyTrash(actionRequest);
        } else if (cmd.equals(Constants.RENAME)) {
            restoreRename(actionRequest);
        } else if (cmd.equals(Constants.RESTORE)) {
            restoreEntries(actionRequest);
        } else if (cmd.equals(Constants.OVERRIDE)) {
            restoreOverride(actionRequest);
        }

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

            sendRedirect(actionRequest, actionResponse, redirect);
        }
    } catch (PrincipalException pe) {
        SessionErrors.add(actionRequest, pe.getClass());

        actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp");
    }
}

From source file:com.liferay.wiki.web.internal.portlet.action.EditPageAttachmentsMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    PortletConfig portletConfig = getPortletConfig(actionRequest);

    try {/*from   w  ww  .j  a v  a 2s  .c  om*/
        UploadException uploadException = (UploadException) actionRequest
                .getAttribute(WebKeys.UPLOAD_EXCEPTION);

        if (uploadException != null) {
            Throwable cause = uploadException.getCause();

            if (uploadException.isExceededFileSizeLimit()) {
                throw new FileSizeException(cause);
            }

            if (uploadException.isExceededLiferayFileItemSizeLimit()) {
                throw new LiferayFileItemException(cause);
            }

            if (uploadException.isExceededUploadRequestSizeLimit()) {
                throw new UploadRequestSizeException(cause);
            }

            throw new PortalException(cause);
        } else if (cmd.equals(Constants.ADD)) {
            _wikiAttachmentsHelper.addAttachments(actionRequest);
        } else if (cmd.equals(Constants.CHECK)) {
            JSONObject jsonObject = RestoreEntryUtil.checkEntry(actionRequest);

            JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);

            return;
        } else if (cmd.equals(Constants.DELETE)) {
            deleteAttachment(actionRequest, false);
        } else if (cmd.equals(Constants.EMPTY_TRASH)) {
            _wikiAttachmentsHelper.emptyTrash(actionRequest);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteAttachment(actionRequest, true);
        } else if (cmd.equals(Constants.RENAME)) {
            _wikiAttachmentsHelper.restoreRename(actionRequest);
        } else if (cmd.equals(Constants.RESTORE)) {
            _wikiAttachmentsHelper.restoreEntries(actionRequest);

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

            if (Validator.isNotNull(redirect)) {
                actionResponse.sendRedirect(redirect);
            }
        } else if (cmd.equals(Constants.OVERRIDE)) {
            _wikiAttachmentsHelper.restoreOverride(actionRequest);
        }
    } catch (NoSuchNodeException | NoSuchPageException | PrincipalException e) {

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

        actionResponse.setRenderParameter("mvcPath", "/wiki/error.jsp");
    } catch (Exception e) {
        handleUploadException(portletConfig, actionRequest, actionResponse, cmd, e);
    }
}