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