001
014
015 package com.liferay.portlet.softwarecatalog.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.portal.util.WebKeys;
021 import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
022 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
023
024 import javax.portlet.PortletConfig;
025 import javax.portlet.RenderRequest;
026 import javax.portlet.RenderResponse;
027
028 import org.apache.struts.action.ActionForm;
029 import org.apache.struts.action.ActionForward;
030 import org.apache.struts.action.ActionMapping;
031
032
035 public class ViewProductEntryAction extends PortletAction {
036
037 public ActionForward render(
038 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
039 RenderRequest renderRequest, RenderResponse renderResponse)
040 throws Exception {
041
042 try {
043 ActionUtil.getProductEntry(renderRequest);
044
045 SCProductEntry productEntry =
046 (SCProductEntry)renderRequest.getAttribute(
047 WebKeys.SOFTWARE_CATALOG_PRODUCT_ENTRY);
048
049 if (productEntry == null) {
050 throw new NoSuchProductEntryException();
051 }
052 }
053 catch (Exception e) {
054 if (e instanceof NoSuchProductEntryException ||
055 e instanceof PrincipalException) {
056
057 SessionErrors.add(renderRequest, e.getClass().getName());
058
059 return mapping.findForward("portlet.software_catalog.error");
060 }
061 else {
062 throw e;
063 }
064 }
065
066 return mapping.findForward(
067 "portlet.software_catalog.view_product_entry");
068 }
069
070 }