1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.communities.action;
16  
17  import com.liferay.portal.NoSuchGroupException;
18  import com.liferay.portal.kernel.servlet.SessionErrors;
19  import com.liferay.portal.security.auth.PrincipalException;
20  import com.liferay.portal.struts.PortletAction;
21  
22  import javax.portlet.PortletConfig;
23  import javax.portlet.RenderRequest;
24  import javax.portlet.RenderResponse;
25  
26  import org.apache.struts.action.ActionForm;
27  import org.apache.struts.action.ActionForward;
28  import org.apache.struts.action.ActionMapping;
29  
30  /**
31   * <a href="ViewMembershipRequestsAction.java.html"><b><i>View Source</i></b>
32   * </a>
33   *
34   * @author Jorge Ferrer
35   */
36  public class ViewMembershipRequestsAction extends PortletAction {
37  
38      public ActionForward render(
39              ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
40              RenderRequest renderRequest, RenderResponse renderResponse)
41          throws Exception {
42  
43          try {
44              ActionUtil.getGroup(renderRequest);
45          }
46          catch (Exception e) {
47              if (e instanceof NoSuchGroupException ||
48                  e instanceof PrincipalException) {
49  
50                  SessionErrors.add(renderRequest, e.getClass().getName());
51  
52                  return mapping.findForward("portlet.communities.error");
53              }
54              else {
55                  throw e;
56              }
57          }
58  
59          return mapping.findForward(getForward(
60              renderRequest, "portlet.communities.view_membership_requests"));
61      }
62  
63  }