Search in sources :

Example 1 with NoSuchMessageException

use of com.liferay.portlet.messageboards.NoSuchMessageException in project liferay-ide by liferay.

the class EditDiscussionAction method processAction.

@Override
public void processAction(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
    try {
        String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            MBMessage message = updateMessage(actionRequest);
            boolean ajax = ParamUtil.getBoolean(actionRequest, "ajax");
            if (ajax) {
                String randomNamespace = ParamUtil.getString(actionRequest, "randomNamespace");
                JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
                jsonObject.put("messageId", message.getMessageId());
                jsonObject.put("randomNamespace", randomNamespace);
                writeJSON(actionRequest, actionResponse, jsonObject);
                return;
            }
        } else if (cmd.equals(Constants.DELETE)) {
            deleteMessage(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE_TO_COMMENTS)) {
            subscribeToComments(actionRequest, true);
        } else if (cmd.equals(Constants.UNSUBSCRIBE_FROM_COMMENTS)) {
            subscribeToComments(actionRequest, false);
        }
        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        if (e instanceof MessageBodyException || e instanceof NoSuchMessageException || e instanceof PrincipalException || e instanceof RequiredMessageException) {
            JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
            jsonObject.putException(e);
            writeJSON(actionRequest, actionResponse, jsonObject);
        } else {
            throw e;
        }
    }
}
Also used : RequiredMessageException(com.liferay.portlet.messageboards.RequiredMessageException) MessageBodyException(com.liferay.portlet.messageboards.MessageBodyException) NoSuchMessageException(com.liferay.portlet.messageboards.NoSuchMessageException) MBMessage(com.liferay.portlet.messageboards.model.MBMessage) JSONObject(com.liferay.portal.kernel.json.JSONObject) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchMessageException(com.liferay.portlet.messageboards.NoSuchMessageException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) MessageBodyException(com.liferay.portlet.messageboards.MessageBodyException) RequiredMessageException(com.liferay.portlet.messageboards.RequiredMessageException)

Aggregations

JSONObject (com.liferay.portal.kernel.json.JSONObject)1 PrincipalException (com.liferay.portal.security.auth.PrincipalException)1 MessageBodyException (com.liferay.portlet.messageboards.MessageBodyException)1 NoSuchMessageException (com.liferay.portlet.messageboards.NoSuchMessageException)1 RequiredMessageException (com.liferay.portlet.messageboards.RequiredMessageException)1 MBMessage (com.liferay.portlet.messageboards.model.MBMessage)1