Search in sources :

Example 1 with ArtistNameException

use of org.liferay.jukebox.ArtistNameException 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 2 with ArtistNameException

use of org.liferay.jukebox.ArtistNameException in project liferay-ide by liferay.

the class JukeboxPortlet method addArtist.

public void addArtist(ActionRequest request, ActionResponse response) throws Exception {
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);
    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.addArtist(name, bio, inputStream, serviceContext);
        SessionMessages.add(request, "artistAdded");
        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)

Aggregations

UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)2 PrincipalException (com.liferay.portal.security.auth.PrincipalException)2 ServiceContext (com.liferay.portal.service.ServiceContext)2 InputStream (java.io.InputStream)2 AlbumNameException (org.liferay.jukebox.AlbumNameException)2 ArtistNameException (org.liferay.jukebox.ArtistNameException)2 DuplicatedSongException (org.liferay.jukebox.DuplicatedSongException)2 SongNameException (org.liferay.jukebox.SongNameException)2 Artist (org.liferay.jukebox.model.Artist)2