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

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

Introduction

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

Prototype

String EMPTY_TRASH

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

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  a v  a  2s .c o  m
        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.EditNodeAttachmentMVCActionCommand.java

License:Open Source License

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

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

    try {//w  ww  . ja v  a  2  s.co m
        if (cmd.equals(Constants.EMPTY_TRASH)) {
            emptyTrash(actionRequest);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchNodeException || e instanceof NoSuchPageException
                || e instanceof PrincipalException) {

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

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 w w  . j av  a 2 s .  com
        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);
    }
}