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