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 @Override
038 public ActionForward render(
039 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
040 RenderRequest renderRequest, RenderResponse renderResponse)
041 throws Exception {
042
043 try {
044 ActionUtil.getProductEntry(renderRequest);
045
046 SCProductEntry productEntry =
047 (SCProductEntry)renderRequest.getAttribute(
048 WebKeys.SOFTWARE_CATALOG_PRODUCT_ENTRY);
049
050 if (productEntry == null) {
051 throw new NoSuchProductEntryException();
052 }
053 }
054 catch (Exception e) {
055 if (e instanceof NoSuchProductEntryException ||
056 e instanceof PrincipalException) {
057
058 SessionErrors.add(renderRequest, e.getClass().getName());
059
060 return mapping.findForward("portlet.software_catalog.error");
061 }
062 else {
063 throw e;
064 }
065 }
066
067 return mapping.findForward(
068 "portlet.software_catalog.view_product_entry");
069 }
070
071 }