001
014
015 package com.liferay.portlet.documentlibrary.action;
016
017 import com.liferay.portal.kernel.servlet.SessionErrors;
018 import com.liferay.portal.security.auth.PrincipalException;
019 import com.liferay.portal.struts.PortletAction;
020 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
021
022 import javax.portlet.PortletConfig;
023 import javax.portlet.PortletContext;
024 import javax.portlet.PortletRequestDispatcher;
025 import javax.portlet.RenderRequest;
026 import javax.portlet.RenderResponse;
027 import javax.portlet.ResourceRequest;
028 import javax.portlet.ResourceResponse;
029
030 import org.apache.struts.action.ActionForm;
031 import org.apache.struts.action.ActionForward;
032 import org.apache.struts.action.ActionMapping;
033
034
038 public class ViewAction extends PortletAction {
039
040 @Override
041 public ActionForward render(
042 ActionMapping actionMapping, ActionForm actionForm,
043 PortletConfig portletConfig, RenderRequest renderRequest,
044 RenderResponse renderResponse)
045 throws Exception {
046
047 try {
048 ActionUtil.getFolder(renderRequest);
049 }
050 catch (Exception e) {
051 if (e instanceof NoSuchFolderException ||
052 e instanceof PrincipalException) {
053
054 SessionErrors.add(renderRequest, e.getClass());
055
056 return actionMapping.findForward(
057 "portlet.document_library.error");
058 }
059 else {
060 throw e;
061 }
062 }
063
064 return actionMapping.findForward("portlet.document_library.view");
065 }
066
067 @Override
068 public void serveResource(
069 ActionMapping actionMapping, ActionForm actionForm,
070 PortletConfig portletConfig, ResourceRequest resourceRequest,
071 ResourceResponse resourceResponse)
072 throws Exception {
073
074 PortletContext portletContext = portletConfig.getPortletContext();
075
076 PortletRequestDispatcher portletRequestDispatcher =
077 portletContext.getRequestDispatcher(
078 "/html/portlet/document_library/view_resources.jsp");
079
080 portletRequestDispatcher.include(resourceRequest, resourceResponse);
081 }
082
083 }