Search in sources :

Example 1 with AlbumNameException

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

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

the class JukeboxPortlet method addAlbum.

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

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 Album (org.liferay.jukebox.model.Album)2