use of com.liferay.portal.security.auth.PrincipalException in project liferay-ide by liferay.
the class DisplayPortlet method render.
@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
try {
KBArticle kbArticle = getKBArticle(renderRequest);
int status = getStatus(renderRequest, kbArticle);
renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
if ((kbArticle != null) && (kbArticle.getStatus() != status)) {
kbArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(kbArticle.getResourcePrimKey(), 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);
}
use of com.liferay.portal.security.auth.PrincipalException 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");
}
}
}
use of com.liferay.portal.security.auth.PrincipalException in project liferay-ide by liferay.
the class JukeboxPortlet method addSong.
public void addSong(ActionRequest request, ActionResponse response) throws Exception {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);
long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
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.addSong(albumId, name, songFileName, songInputStream, lyricsFileName, lyricsInputStream, serviceContext);
SessionMessages.add(request, "songAdded");
String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
} catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof SongNameException || e instanceof DuplicatedSongException || e instanceof PrincipalException) {
response.setRenderParameter("jspPage", "/html/songs/edit_song.jsp");
} else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
use of com.liferay.portal.security.auth.PrincipalException 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");
}
}
}
use of com.liferay.portal.security.auth.PrincipalException in project liferay-ide by liferay.
the class SearchPortlet 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 = ParamUtil.getLong(renderRequest, "resourcePrimKey");
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());
} else {
throw new PortletException(e);
}
}
super.render(renderRequest, renderResponse);
}
Aggregations