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

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

Introduction

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

Prototype

String VOTE

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

Click Source Link

Usage

From source file:com.liferay.polls.web.internal.portlet.action.EditQuestionMVCActionCommand.java

License:Open Source License

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

    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

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

    try {/*ww  w. ja  v  a2  s. c o  m*/
        if (Validator.isNull(cmd)) {
            return;
        } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE) || cmd.equals(Constants.VOTE)) {

            updateQuestion(portletConfig, actionRequest, actionResponse);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteQuestion(actionRequest);
        }

        WindowState windowState = actionRequest.getWindowState();

        if (windowState.equals(LiferayWindowState.POP_UP)) {
            String redirect = portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

            if (Validator.isNotNull(redirect)) {
                actionResponse.sendRedirect(redirect);
            }
        } else {
            sendRedirect(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchQuestionException || e instanceof PrincipalException) {

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

            actionResponse.setRenderParameter("mvcPath", "/polls/error.jsp");
        } else if (e instanceof DuplicateVoteException || e instanceof NoSuchChoiceException
                || e instanceof QuestionChoiceException || e instanceof QuestionDescriptionException
                || e instanceof QuestionExpirationDateException || e instanceof QuestionTitleException) {

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

            hideDefaultErrorMessage(actionRequest);
        } else if (e instanceof QuestionExpiredException) {
        } else {
            throw e;
        }
    }
}