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