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

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

Introduction

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

Prototype

String UNLOCK

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

Click Source Link

Usage

From source file:com.liferay.message.boards.web.internal.portlet.action.EditEntryMVCActionCommand.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  .j a va  2s. com
        if (cmd.equals(Constants.DELETE)) {
            deleteEntries(actionRequest, false);
        } else if (cmd.equals(Constants.LOCK)) {
            lockThreads(actionRequest);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteEntries(actionRequest, true);
        } else if (cmd.equals(Constants.UNLOCK)) {
            unlockThreads(actionRequest);
        }
    } catch (LockedThreadException | PrincipalException e) {
        SessionErrors.add(actionRequest, e.getClass());

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

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

License:Open Source License

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

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

    MBMessage message = null;//  w w w. j a  v  a 2  s  .  c o m

    try {
        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) || cmd.equals(Constants.UPDATE)) {

            message = updateMessage(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.ADD_ANSWER)) {
            addAnswer(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteMessage(actionRequest);
        } else if (cmd.equals(Constants.DELETE_ANSWER)) {
            deleteAnswer(actionRequest);
        } else if (cmd.equals(Constants.LOCK)) {
            lockThreads(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeMessage(actionRequest);
        } else if (cmd.equals(Constants.UNLOCK)) {
            unlockThreads(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeMessage(actionRequest);
        }

        if (Validator.isNotNull(cmd)) {
            WindowState windowState = actionRequest.getWindowState();

            if (!windowState.equals(LiferayWindowState.POP_UP)) {
                String redirect = getRedirect(actionRequest, actionResponse, message);

                sendRedirect(actionRequest, actionResponse, redirect);
            } else {
                String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

                if (Validator.isNotNull(redirect)) {
                    actionResponse.sendRedirect(redirect);
                }
            }
        }
    } catch (NoSuchMessageException | PrincipalException | RequiredMessageException e) {

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

        actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp");
    } catch (AntivirusScannerException | CaptchaConfigurationException | CaptchaTextException
            | DuplicateFileEntryException | FileExtensionException | FileNameException | FileSizeException
            | LiferayFileItemException | LockedThreadException | MessageBodyException | MessageSubjectException
            | SanitizerException | UploadRequestSizeException e) {

        if (e instanceof AntivirusScannerException) {
            SessionErrors.add(actionRequest, e.getClass(), e);
        } else {
            SessionErrors.add(actionRequest, e.getClass());
        }
    } catch (AssetCategoryException | AssetTagException e) {
        SessionErrors.add(actionRequest, e.getClass(), e);
    } catch (Exception e) {
        Throwable cause = e.getCause();

        if (cause instanceof SanitizerException) {
            SessionErrors.add(actionRequest, SanitizerException.class);
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.ThreadLockPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    PortletURL portletURL = PortalUtil.getControlPanelPortletURL(portletRequest,
            MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.ACTION_PHASE);

    portletURL.setParameter(ActionRequest.ACTION_NAME, "/message_boards/edit_message");

    try {/* w  ww .j a  va 2  s . c om*/
        MBMessage message = ActionUtil.getMessage(portletRequest);

        MBThread thread = message.getThread();

        if (thread.isLocked()) {
            portletURL.setParameter(Constants.CMD, Constants.UNLOCK);
        } else {
            portletURL.setParameter(Constants.CMD, Constants.LOCK);
        }

        portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest));
        portletURL.setParameter("threadId", String.valueOf(thread.getThreadId()));
    } catch (Exception e) {
        return null;
    }

    return portletURL.toString();
}

From source file:com.liferay.portlet.documentlibrary.action.EditFileEntryAction.java

License:Open Source License

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

    FileEntryForm fileEntryForm = (FileEntryForm) form;

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

    try {//from w  w w  .ja va2  s .  c  o m
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFileEntry(fileEntryForm, actionRequest, actionResponse);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFileEntry(actionRequest);
        } else if (cmd.equals(Constants.LOCK)) {
            lockFileEntry(actionRequest);
        } else if (cmd.equals(Constants.UNLOCK)) {
            unlockFileEntry(actionRequest);
        }

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

            if (e instanceof DuplicateLockException) {
                DuplicateLockException dle = (DuplicateLockException) e;

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

            setForward(actionRequest, "portlet.document_library.error");
        } else if (e instanceof DuplicateFileException || e instanceof DuplicateFolderNameException
                || e instanceof FileNameException || e instanceof FileSizeException
                || e instanceof NoSuchFolderException || e instanceof SourceFileNameException) {

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