001
014
015 package com.liferay.portlet.requests.action;
016
017 import com.liferay.portal.model.Group;
018 import com.liferay.portal.model.User;
019 import com.liferay.portal.security.permission.ActionKeys;
020 import com.liferay.portal.service.GroupLocalServiceUtil;
021 import com.liferay.portal.service.UserLocalServiceUtil;
022 import com.liferay.portal.service.permission.UserPermissionUtil;
023 import com.liferay.portal.struts.PortletAction;
024 import com.liferay.portal.theme.ThemeDisplay;
025 import com.liferay.portal.util.WebKeys;
026 import com.liferay.portlet.social.model.SocialRequest;
027 import com.liferay.portlet.social.model.SocialRequestConstants;
028 import com.liferay.portlet.social.service.SocialRequestLocalServiceUtil;
029
030 import java.util.List;
031
032 import javax.portlet.PortletConfig;
033 import javax.portlet.RenderRequest;
034 import javax.portlet.RenderResponse;
035
036 import org.apache.struts.action.ActionForm;
037 import org.apache.struts.action.ActionForward;
038 import org.apache.struts.action.ActionMapping;
039
040
043 public class ViewAction extends PortletAction {
044
045 @Override
046 public ActionForward render(
047 ActionMapping actionMapping, ActionForm actionForm,
048 PortletConfig portletConfig, RenderRequest renderRequest,
049 RenderResponse renderResponse)
050 throws Exception {
051
052 ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(
053 WebKeys.THEME_DISPLAY);
054
055 Group group = GroupLocalServiceUtil.getGroup(
056 themeDisplay.getScopeGroupId());
057
058 User user = themeDisplay.getUser();
059
060 if (group.isUser()) {
061 user = UserLocalServiceUtil.getUserById(group.getClassPK());
062 }
063
064 if (UserPermissionUtil.contains(
065 themeDisplay.getPermissionChecker(), user.getUserId(),
066 ActionKeys.UPDATE)) {
067
068 List<SocialRequest> requests =
069 SocialRequestLocalServiceUtil.getReceiverUserRequests(
070 user.getUserId(), SocialRequestConstants.STATUS_PENDING, 0,
071 100);
072
073 renderRequest.setAttribute(WebKeys.SOCIAL_REQUESTS, requests);
074 }
075
076 return actionMapping.findForward("portlet.requests.view");
077 }
078
079 }