1
22
23 package com.liferay.portal.service.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.security.permission.ActionKeys;
28 import com.liferay.portal.model.Group;
29 import com.liferay.portal.service.GroupLocalServiceUtil;
30 import com.liferay.portal.service.GroupService;
31 import com.liferay.portal.service.permission.GroupPermissionUtil;
32 import com.liferay.portal.service.permission.PortalPermissionUtil;
33 import com.liferay.portal.service.permission.RolePermissionUtil;
34 import com.liferay.util.MapUtil;
35
36 import java.util.LinkedHashMap;
37 import java.util.List;
38
39
45 public class GroupServiceImpl extends PrincipalBean implements GroupService {
46
47 public Group addGroup(
48 String name, String description, String type, String friendlyURL,
49 boolean active)
50 throws PortalException, SystemException {
51
52 PortalPermissionUtil.check(
53 getPermissionChecker(), ActionKeys.ADD_COMMUNITY);
54
55 return GroupLocalServiceUtil.addGroup(
56 getUserId(), null, 0, name, description, type, friendlyURL, active);
57 }
58
59 public Group addGroup(
60 long liveGroupId, String name, String description, String type,
61 String friendlyURL, boolean active)
62 throws PortalException, SystemException {
63
64 GroupPermissionUtil.check(
65 getPermissionChecker(), liveGroupId, ActionKeys.UPDATE);
66
67 return GroupLocalServiceUtil.addGroup(
68 getUserId(), null, 0, liveGroupId, name, description, type,
69 friendlyURL, active);
70 }
71
72 public void addRoleGroups(long roleId, long[] groupIds)
73 throws PortalException, SystemException {
74
75 RolePermissionUtil.check(
76 getPermissionChecker(), roleId, ActionKeys.UPDATE);
77
78 GroupLocalServiceUtil.addRoleGroups(roleId, groupIds);
79 }
80
81 public void deleteGroup(long groupId)
82 throws PortalException, SystemException {
83
84 GroupPermissionUtil.check(
85 getPermissionChecker(), groupId, ActionKeys.DELETE);
86
87 GroupLocalServiceUtil.deleteGroup(groupId);
88 }
89
90 public Group getGroup(long groupId)
91 throws PortalException, SystemException {
92
93 return GroupLocalServiceUtil.getGroup(groupId);
94 }
95
96 public Group getGroup(long companyId, String name)
97 throws PortalException, SystemException {
98
99 return GroupLocalServiceUtil.getGroup(companyId, name);
100 }
101
102 public List getOrganizationsGroups(List organizations)
103 throws PortalException, SystemException {
104
105 return GroupLocalServiceUtil.getOrganizationsGroups(organizations);
106 }
107
108 public List getUserGroupsGroups(List userGroups)
109 throws PortalException, SystemException {
110
111 return GroupLocalServiceUtil.getUserGroupsGroups(userGroups);
112 }
113
114 public boolean hasUserGroup(long userId, long groupId)
115 throws SystemException {
116
117 return GroupLocalServiceUtil.hasUserGroup(userId, groupId);
118 }
119
120 public List search(
121 long companyId, String name, String description, String[] params,
122 int begin, int end)
123 throws SystemException {
124
125 LinkedHashMap paramsObj = MapUtil.toLinkedHashMap(params);
126
127 return GroupLocalServiceUtil.search(
128 companyId, name, description, paramsObj, begin, end);
129 }
130
131 public int searchCount(
132 long companyId, String name, String description, String[] params)
133 throws SystemException {
134
135 LinkedHashMap paramsObj = MapUtil.toLinkedHashMap(params);
136
137 return GroupLocalServiceUtil.searchCount(
138 companyId, name, description, paramsObj);
139 }
140
141 public void setRoleGroups(long roleId, long[] groupIds)
142 throws PortalException, SystemException {
143
144 RolePermissionUtil.check(
145 getPermissionChecker(), roleId, ActionKeys.UPDATE);
146
147 GroupLocalServiceUtil.setRoleGroups(roleId, groupIds);
148 }
149
150 public void unsetRoleGroups(long roleId, long[] groupIds)
151 throws PortalException, SystemException {
152
153 RolePermissionUtil.check(
154 getPermissionChecker(), roleId, ActionKeys.UPDATE);
155
156 GroupLocalServiceUtil.unsetRoleGroups(roleId, groupIds);
157 }
158
159 public Group updateGroup(
160 long groupId, String name, String description, String type,
161 String friendlyURL, boolean active)
162 throws PortalException, SystemException {
163
164 GroupPermissionUtil.check(
165 getPermissionChecker(), groupId, ActionKeys.UPDATE);
166
167 return GroupLocalServiceUtil.updateGroup(
168 groupId, name, description, type, friendlyURL, active);
169 }
170
171 public Group updateGroup(long groupId, String typeSettings)
172 throws PortalException, SystemException {
173
174 GroupPermissionUtil.check(
175 getPermissionChecker(), groupId, ActionKeys.UPDATE);
176
177 return GroupLocalServiceUtil.updateGroup(groupId, typeSettings);
178 }
179
180 }