Search in sources :

Example 16 with PrincipalException

use of com.liferay.portal.security.auth.PrincipalException in project liferay-ide by liferay.

the class EditConfigurationAction method serveResource.

@Override
public void serveResource(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    Portlet portlet = null;
    try {
        portlet = ActionUtil.getPortlet(resourceRequest);
    } catch (PrincipalException pe) {
        return;
    }
    resourceRequest = ActionUtil.getWrappedResourceRequest(resourceRequest, null);
    ResourceServingConfigurationAction resourceServingConfigurationAction = (ResourceServingConfigurationAction) getConfigurationAction(portlet);
    if (resourceServingConfigurationAction == null) {
        return;
    }
    resourceServingConfigurationAction.serveResource(portletConfig, resourceRequest, resourceResponse);
}
Also used : Portlet(com.liferay.portal.model.Portlet) PrincipalException(com.liferay.portal.security.auth.PrincipalException) ResourceServingConfigurationAction(com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)

Example 17 with PrincipalException

use of com.liferay.portal.security.auth.PrincipalException in project liferay-ide by liferay.

the class EditConfigurationAction method processAction.

@Override
public void processAction(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    Portlet portlet = null;
    try {
        portlet = ActionUtil.getPortlet(actionRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(actionRequest, PrincipalException.class.getName());
        setForward(actionRequest, "portlet.portlet_configuration.error");
        return;
    }
    actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, null);
    ConfigurationAction configurationAction = getConfigurationAction(portlet);
    if (configurationAction == null) {
        return;
    }
    configurationAction.processAction(portletConfig, actionRequest, actionResponse);
}
Also used : Portlet(com.liferay.portal.model.Portlet) PrincipalException(com.liferay.portal.security.auth.PrincipalException) ConfigurationAction(com.liferay.portal.kernel.portlet.ConfigurationAction) ResourceServingConfigurationAction(com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)

Example 18 with PrincipalException

use of com.liferay.portal.security.auth.PrincipalException in project liferay-ide by liferay.

the class EditConfigurationAction method render.

@Override
public ActionForward render(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
    Portlet portlet = null;
    try {
        portlet = ActionUtil.getPortlet(renderRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(renderRequest, PrincipalException.class.getName());
        return actionMapping.findForward("portlet.portlet_configuration.error");
    }
    renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, null);
    renderResponse.setTitle(ActionUtil.getTitle(portlet, renderRequest));
    ConfigurationAction configurationAction = getConfigurationAction(portlet);
    if (configurationAction != null) {
        String path = configurationAction.render(portletConfig, renderRequest, renderResponse);
        if (_log.isDebugEnabled()) {
            _log.debug("Configuration action returned render path " + path);
        }
        if (Validator.isNotNull(path)) {
            renderRequest.setAttribute(WebKeys.CONFIGURATION_ACTION_PATH, path);
        } else {
            _log.error("Configuration action returned a null path");
        }
    }
    return actionMapping.findForward(getForward(renderRequest, "portlet.portlet_configuration.edit_configuration"));
}
Also used : Portlet(com.liferay.portal.model.Portlet) PrincipalException(com.liferay.portal.security.auth.PrincipalException) ConfigurationAction(com.liferay.portal.kernel.portlet.ConfigurationAction) ResourceServingConfigurationAction(com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)

Example 19 with PrincipalException

use of com.liferay.portal.security.auth.PrincipalException 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

PrincipalException (com.liferay.portal.security.auth.PrincipalException)19 IOException (java.io.IOException)8 SystemException (com.liferay.portal.kernel.exception.SystemException)7 PortalException (com.liferay.portal.kernel.exception.PortalException)6 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)6 ServiceContext (com.liferay.portal.service.ServiceContext)6 InputStream (java.io.InputStream)6 AlbumNameException (org.liferay.jukebox.AlbumNameException)6 ArtistNameException (org.liferay.jukebox.ArtistNameException)6 DuplicatedSongException (org.liferay.jukebox.DuplicatedSongException)6 SongNameException (org.liferay.jukebox.SongNameException)6 NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)5 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)5 KBArticle (com.liferay.knowledgebase.model.KBArticle)5 NoSuchSubscriptionException (com.liferay.portal.NoSuchSubscriptionException)5 PortletException (javax.portlet.PortletException)5 NoSuchGroupException (com.liferay.portal.NoSuchGroupException)3 ResourceServingConfigurationAction (com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)3 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)3 Portlet (com.liferay.portal.model.Portlet)3