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(
104 List<Organization> organizations) {
105
106 return groupLocalService.getOrganizationsGroups(organizations);
107 }
108
109 public List<Group> getUserGroupsGroups(List<UserGroup> userGroups) {
110 return groupLocalService.getUserGroupsGroups(userGroups);
111 }
112
113 public boolean hasUserGroup(long userId, long groupId)
114 throws SystemException {
115
116 return groupLocalService.hasUserGroup(userId, groupId);
117 }
118
119 public List<Group> search(
120 long companyId, String name, String description, String[] params,
121 int start, int end)
122 throws SystemException {
123
124 LinkedHashMap<String, Object> paramsObj = MapUtil.toLinkedHashMap(
125 params);
126
127 return groupLocalService.search(
128 companyId, name, description, paramsObj, start, end);
129 }
130
131 public int searchCount(
132 long companyId, String name, String description, String[] params)
133 throws SystemException {
134
135 LinkedHashMap<String, Object> paramsObj = MapUtil.toLinkedHashMap(
136 params);
137
138 return groupLocalService.searchCount(
139 companyId, name, description, paramsObj);
140 }
141
142 public void setRoleGroups(long roleId, long[] groupIds)
143 throws PortalException, SystemException {
144
145 RolePermissionUtil.check(
146 getPermissionChecker(), roleId, ActionKeys.UPDATE);
147
148 groupLocalService.setRoleGroups(roleId, groupIds);
149 }
150
151 public void unsetRoleGroups(long roleId, long[] groupIds)
152 throws PortalException, SystemException {
153
154 RolePermissionUtil.check(
155 getPermissionChecker(), roleId, ActionKeys.UPDATE);
156
157 groupLocalService.unsetRoleGroups(roleId, groupIds);
158 }
159
160 public Group updateFriendlyURL(long groupId, String friendlyURL)
161 throws PortalException, SystemException {
162
163 GroupPermissionUtil.check(
164 getPermissionChecker(), groupId, ActionKeys.UPDATE);
165
166 return groupLocalService.updateFriendlyURL(groupId, friendlyURL);
167 }
168
169 public Group updateGroup(
170 long groupId, String name, String description, int type,
171 String friendlyURL, boolean active)
172 throws PortalException, SystemException {
173
174 GroupPermissionUtil.check(
175 getPermissionChecker(), groupId, ActionKeys.UPDATE);
176
177 return groupLocalService.updateGroup(
178 groupId, name, description, type, friendlyURL, active);
179 }
180
181 public Group updateGroup(long groupId, String typeSettings)
182 throws PortalException, SystemException {
183
184 GroupPermissionUtil.check(
185 getPermissionChecker(), groupId, ActionKeys.UPDATE);
186
187 return groupLocalService.updateGroup(groupId, typeSettings);
188 }
189
190 public Group updateWorkflow(
191 long groupId, boolean workflowEnabled, int workflowStages,
192 String workflowRoleNames)
193 throws PortalException, SystemException {
194
195 GroupPermissionUtil.check(
196 getPermissionChecker(), groupId, ActionKeys.MANAGE_STAGING);
197
198 return groupLocalService.updateWorkflow(
199 groupId, workflowEnabled, workflowStages, workflowRoleNames);
200 }
201
202 }