Search in sources :

Example 6 with PrincipalException

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

the class JukeboxPortlet method updateArtist.

public void updateArtist(ActionRequest request, ActionResponse response) throws Exception {
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);
    long artistId = ParamUtil.getLong(uploadPortletRequest, "artistId");
    String name = ParamUtil.getString(uploadPortletRequest, "name");
    String bio = ParamUtil.getString(uploadPortletRequest, "bio");
    InputStream inputStream = uploadPortletRequest.getFileAsStream("file");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Artist.class.getName(), uploadPortletRequest);
    try {
        ArtistServiceUtil.updateArtist(artistId, name, bio, inputStream, serviceContext);
        SessionMessages.add(request, "artistUpdated");
        String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");
        response.sendRedirect(redirect);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());
        if (e instanceof ArtistNameException || e instanceof PrincipalException) {
            response.setRenderParameter("jspPage", "/html/artists/edit_artist.jsp");
        } else {
            response.setRenderParameter("jspPage", "/html/error.jsp");
        }
    }
}
Also used : Artist(org.liferay.jukebox.model.Artist) ArtistNameException(org.liferay.jukebox.ArtistNameException) InputStream(java.io.InputStream) ServiceContext(com.liferay.portal.service.ServiceContext) PrincipalException(com.liferay.portal.security.auth.PrincipalException) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) SongNameException(org.liferay.jukebox.SongNameException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) DuplicatedSongException(org.liferay.jukebox.DuplicatedSongException) AlbumNameException(org.liferay.jukebox.AlbumNameException) ArtistNameException(org.liferay.jukebox.ArtistNameException)

Example 7 with PrincipalException

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

the class JukeboxPortlet method updateSong.

public void updateSong(ActionRequest request, ActionResponse response) throws Exception {
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);
    long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
    long songId = ParamUtil.getLong(uploadPortletRequest, "songId");
    String name = ParamUtil.getString(uploadPortletRequest, "name");
    InputStream songInputStream = uploadPortletRequest.getFileAsStream("songFile");
    String songFileName = uploadPortletRequest.getFileName("songFile");
    InputStream lyricsInputStream = uploadPortletRequest.getFileAsStream("lyricsFile");
    String lyricsFileName = uploadPortletRequest.getFileName("lyricsFile");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Song.class.getName(), uploadPortletRequest);
    try {
        SongServiceUtil.updateSong(songId, albumId, name, songFileName, songInputStream, lyricsFileName, lyricsInputStream, serviceContext);
        SessionMessages.add(request, "songUpdated");
        String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");
        response.sendRedirect(redirect);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());
        if (e instanceof SongNameException || e instanceof PrincipalException) {
            response.setRenderParameter("jspPage", "/html/songs/edit_song.jsp");
        } else {
            response.setRenderParameter("jspPage", "/html/error.jsp");
        }
    }
}
Also used : Song(org.liferay.jukebox.model.Song) SongNameException(org.liferay.jukebox.SongNameException) InputStream(java.io.InputStream) ServiceContext(com.liferay.portal.service.ServiceContext) PrincipalException(com.liferay.portal.security.auth.PrincipalException) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) SongNameException(org.liferay.jukebox.SongNameException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) DuplicatedSongException(org.liferay.jukebox.DuplicatedSongException) AlbumNameException(org.liferay.jukebox.AlbumNameException) ArtistNameException(org.liferay.jukebox.ArtistNameException)

Example 8 with PrincipalException

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

the class JukeboxPortlet method updateAlbum.

public void updateAlbum(ActionRequest request, ActionResponse response) throws Exception {
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);
    long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
    long artistId = ParamUtil.getLong(uploadPortletRequest, "artistId");
    String name = ParamUtil.getString(uploadPortletRequest, "name");
    int year = ParamUtil.getInteger(uploadPortletRequest, "year");
    InputStream inputStream = uploadPortletRequest.getFileAsStream("file");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Album.class.getName(), uploadPortletRequest);
    try {
        AlbumServiceUtil.updateAlbum(albumId, artistId, name, year, inputStream, serviceContext);
        SessionMessages.add(request, "albumUpdated");
        String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");
        response.sendRedirect(redirect);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());
        if (e instanceof AlbumNameException || e instanceof PrincipalException) {
            response.setRenderParameter("jspPage", "/html/albums/edit_album.jsp");
        } else {
            response.setRenderParameter("jspPage", "/html/error.jsp");
        }
    }
}
Also used : InputStream(java.io.InputStream) ServiceContext(com.liferay.portal.service.ServiceContext) PrincipalException(com.liferay.portal.security.auth.PrincipalException) Album(org.liferay.jukebox.model.Album) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) AlbumNameException(org.liferay.jukebox.AlbumNameException) SongNameException(org.liferay.jukebox.SongNameException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) DuplicatedSongException(org.liferay.jukebox.DuplicatedSongException) AlbumNameException(org.liferay.jukebox.AlbumNameException) ArtistNameException(org.liferay.jukebox.ArtistNameException)

Example 9 with PrincipalException

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

the class SectionPortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        int status = getStatus(renderRequest);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        KBArticle kbArticle = getKBArticle(renderRequest, status);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
    } catch (Exception e) {
        if (e instanceof NoSuchArticleException || e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass());
        } else {
            throw new PortletException(e);
        }
    }
    super.render(renderRequest, renderResponse);
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) PortletException(javax.portlet.PortletException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) NoSuchSubscriptionException(com.liferay.portal.NoSuchSubscriptionException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) IOException(java.io.IOException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) PortletException(javax.portlet.PortletException)

Example 10 with PrincipalException

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

the class ArticlePortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        int status = getStatus(renderRequest);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        KBArticle kbArticle = null;
        long resourcePrimKey = getResourcePrimKey(renderRequest);
        if (resourcePrimKey > 0) {
            kbArticle = KBArticleServiceUtil.getLatestKBArticle(resourcePrimKey, status);
        }
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
    } catch (Exception e) {
        if (e instanceof NoSuchArticleException || e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass());
            SessionMessages.add(renderRequest, PortalUtil.getPortletId(renderRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
        } else {
            throw new PortletException(e);
        }
    }
    super.render(renderRequest, renderResponse);
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) PortletException(javax.portlet.PortletException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) NoSuchSubscriptionException(com.liferay.portal.NoSuchSubscriptionException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) IOException(java.io.IOException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) PortletException(javax.portlet.PortletException)

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