1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.communities.action;
21  
22  import com.liferay.portal.kernel.util.ParamUtil;
23  import com.liferay.portal.model.Group;
24  import com.liferay.portal.model.MembershipRequest;
25  import com.liferay.portal.service.GroupLocalServiceUtil;
26  import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
27  import com.liferay.portal.util.PortalUtil;
28  import com.liferay.portal.util.WebKeys;
29  
30  import javax.portlet.ActionRequest;
31  import javax.portlet.RenderRequest;
32  
33  import javax.servlet.http.HttpServletRequest;
34  
35  /**
36   * <a href="ActionUtil.java.html"><b><i>View Source</i></b></a>
37   *
38   * @author Brian Wing Shun Chan
39   *
40   */
41  public class ActionUtil
42      extends com.liferay.portlet.enterpriseadmin.action.ActionUtil {
43  
44      public static void getGroup(ActionRequest actionRequest) throws Exception {
45          HttpServletRequest request = PortalUtil.getHttpServletRequest(
46              actionRequest);
47  
48          getGroup(request);
49      }
50  
51      public static void getGroup(RenderRequest renderRequest) throws Exception {
52          HttpServletRequest request = PortalUtil.getHttpServletRequest(
53              renderRequest);
54  
55          getGroup(request);
56      }
57  
58      public static void getGroup(HttpServletRequest request) throws Exception {
59          long groupId = ParamUtil.getLong(request, "groupId");
60  
61          Group group = null;
62  
63          if (groupId > 0) {
64              group = GroupLocalServiceUtil.getGroup(groupId);
65          }
66  
67          request.setAttribute(WebKeys.GROUP, group);
68      }
69  
70      public static void getMembershipRequest(ActionRequest actionRequest)
71          throws Exception {
72  
73          HttpServletRequest request = PortalUtil.getHttpServletRequest(
74              actionRequest);
75  
76          getMembershipRequest(request);
77      }
78  
79      public static void getMembershipRequest(RenderRequest renderRequest)
80          throws Exception {
81  
82          HttpServletRequest request = PortalUtil.getHttpServletRequest(
83              renderRequest);
84  
85          getMembershipRequest(request);
86      }
87  
88      public static void getMembershipRequest(HttpServletRequest request)
89          throws Exception {
90  
91          long membershipRequestId =
92              ParamUtil.getLong(request, "membershipRequestId");
93  
94          MembershipRequest membershipRequest = null;
95  
96          if (membershipRequestId > 0) {
97              membershipRequest =
98                  MembershipRequestLocalServiceUtil.getMembershipRequest(
99                      membershipRequestId);
100         }
101 
102         request.setAttribute(WebKeys.MEMBERSHIP_REQUEST, membershipRequest);
103     }
104 
105 }