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");
}
}
}
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");
}
}
}
Aggregations