001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.communities.action;
022:
023: import com.liferay.portal.kernel.util.ParamUtil;
024: import com.liferay.portal.model.Group;
025: import com.liferay.portal.model.MembershipRequest;
026: import com.liferay.portal.service.GroupLocalServiceUtil;
027: import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
028: import com.liferay.portal.util.PortalUtil;
029: import com.liferay.portal.util.WebKeys;
030:
031: import javax.portlet.ActionRequest;
032: import javax.portlet.RenderRequest;
033:
034: import javax.servlet.http.HttpServletRequest;
035:
036: /**
037: * <a href="ActionUtil.java.html"><b><i>View Source</i></b></a>
038: *
039: * @author Brian Wing Shun Chan
040: *
041: */
042: public class ActionUtil extends
043: com.liferay.portlet.enterpriseadmin.action.ActionUtil {
044:
045: public static void getGroup(ActionRequest req) throws Exception {
046: HttpServletRequest httpReq = PortalUtil
047: .getHttpServletRequest(req);
048:
049: getGroup(httpReq);
050: }
051:
052: public static void getGroup(RenderRequest req) throws Exception {
053: HttpServletRequest httpReq = PortalUtil
054: .getHttpServletRequest(req);
055:
056: getGroup(httpReq);
057: }
058:
059: public static void getGroup(HttpServletRequest req)
060: throws Exception {
061: long groupId = ParamUtil.getLong(req, "groupId");
062:
063: Group group = null;
064:
065: if (groupId > 0) {
066: group = GroupLocalServiceUtil.getGroup(groupId);
067: }
068:
069: req.setAttribute(WebKeys.GROUP, group);
070: }
071:
072: public static void getMembershipRequest(ActionRequest req)
073: throws Exception {
074:
075: HttpServletRequest httpReq = PortalUtil
076: .getHttpServletRequest(req);
077:
078: getMembershipRequest(httpReq);
079: }
080:
081: public static void getMembershipRequest(RenderRequest req)
082: throws Exception {
083:
084: HttpServletRequest httpReq = PortalUtil
085: .getHttpServletRequest(req);
086:
087: getMembershipRequest(httpReq);
088: }
089:
090: public static void getMembershipRequest(HttpServletRequest req)
091: throws Exception {
092:
093: long membershipRequestId = ParamUtil.getLong(req,
094: "membershipRequestId");
095:
096: MembershipRequest membershipRequest = null;
097:
098: if (membershipRequestId > 0) {
099: membershipRequest = MembershipRequestLocalServiceUtil
100: .getMembershipRequest(membershipRequestId);
101: }
102:
103: req.setAttribute(WebKeys.MEMBERSHIP_REQUEST, membershipRequest);
104: }
105:
106: }
|