List of usage examples for com.liferay.portal.kernel.util PortalUtil sendError
public static void sendError(int status, Exception e, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException
From source file:com.liferay.document.library.web.internal.portlet.action.GetFileActionHelper.java
License:Open Source License
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { try {// www.j a v a 2 s .co m long fileEntryId = ParamUtil.getLong(request, "fileEntryId"); long folderId = ParamUtil.getLong(request, "folderId"); String name = ParamUtil.getString(request, "name"); String title = ParamUtil.getString(request, "title"); String version = ParamUtil.getString(request, "version"); long fileShortcutId = ParamUtil.getLong(request, "fileShortcutId"); String uuid = ParamUtil.getString(request, "uuid"); String targetExtension = ParamUtil.getString(request, "targetExtension"); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(request, "groupId", themeDisplay.getScopeGroupId()); getFile(fileEntryId, folderId, name, title, version, fileShortcutId, uuid, groupId, targetExtension, request, response); } catch (NoSuchFileEntryException nsfee) { PortalUtil.sendError(HttpServletResponse.SC_NOT_FOUND, nsfee, request, response); } catch (PrincipalException pe) { processPrincipalException(pe, request, response); } catch (Exception e) { PortalUtil.sendError(e, request, response); } }
From source file:com.liferay.document.library.web.internal.portlet.action.GetFileActionHelper.java
License:Open Source License
protected void processPrincipalException(Throwable t, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); User user = permissionChecker.getUser(); if ((user != null) && !user.isDefaultUser()) { PortalUtil.sendError(HttpServletResponse.SC_UNAUTHORIZED, (Exception) t, request, response); return;/*from w w w .j a v a 2 s. co m*/ } String redirect = PortalUtil.getPathMain() + "/portal/login"; String currentURL = PortalUtil.getCurrentURL(request); redirect = HttpUtil.addParameter(redirect, "redirect", currentURL); response.sendRedirect(redirect); }