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