001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.usersadmin.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.search.Hits;
020    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
021    import com.liferay.portal.kernel.util.OrderByComparator;
022    import com.liferay.portal.kernel.util.Tuple;
023    import com.liferay.portal.model.Address;
024    import com.liferay.portal.model.EmailAddress;
025    import com.liferay.portal.model.Group;
026    import com.liferay.portal.model.OrgLabor;
027    import com.liferay.portal.model.Organization;
028    import com.liferay.portal.model.Phone;
029    import com.liferay.portal.model.Role;
030    import com.liferay.portal.model.User;
031    import com.liferay.portal.model.UserGroup;
032    import com.liferay.portal.model.UserGroupRole;
033    import com.liferay.portal.model.Website;
034    import com.liferay.portal.security.permission.PermissionChecker;
035    
036    import java.util.List;
037    
038    import javax.portlet.ActionRequest;
039    import javax.portlet.PortletRequest;
040    import javax.portlet.RenderResponse;
041    
042    import javax.servlet.http.HttpServletRequest;
043    
044    /**
045     * @author Brian Wing Shun Chan
046     * @author Jorge Ferrer
047     * @author Julio Camarero
048     */
049    public class UsersAdminUtil {
050    
051            public static final String CUSTOM_QUESTION = "write-my-own-question";
052    
053            public static void addPortletBreadcrumbEntries(
054                            Organization organization, HttpServletRequest request,
055                            RenderResponse renderResponse)
056                    throws Exception {
057    
058                    getUsersAdmin().addPortletBreadcrumbEntries(
059                            organization, request, renderResponse);
060            }
061    
062            public static long[] addRequiredRoles(long userId, long[] roleIds)
063                    throws PortalException, SystemException {
064    
065                    return getUsersAdmin().addRequiredRoles(userId, roleIds);
066            }
067    
068            public static long[] addRequiredRoles(User user, long[] roleIds)
069                    throws PortalException, SystemException {
070    
071                    return getUsersAdmin().addRequiredRoles(user, roleIds);
072            }
073    
074            public static List<Role> filterGroupRoles(
075                            PermissionChecker permissionChecker, long groupId, List<Role> roles)
076                    throws PortalException, SystemException {
077    
078                    return getUsersAdmin().filterGroupRoles(
079                            permissionChecker, groupId, roles);
080            }
081    
082            public static List<Group> filterGroups(
083                            PermissionChecker permissionChecker, List<Group> groups)
084                    throws PortalException, SystemException {
085    
086                    return getUsersAdmin().filterGroups(permissionChecker, groups);
087            }
088    
089            public static List<Organization> filterOrganizations(
090                            PermissionChecker permissionChecker,
091                            List<Organization> organizations)
092                    throws PortalException, SystemException {
093    
094                    return getUsersAdmin().filterOrganizations(
095                            permissionChecker, organizations);
096            }
097    
098            public static List<Role> filterRoles(
099                    PermissionChecker permissionChecker, List<Role> roles) {
100    
101                    return getUsersAdmin().filterRoles(permissionChecker, roles);
102            }
103    
104            public static List<UserGroupRole> filterUserGroupRoles(
105                            PermissionChecker permissionChecker,
106                            List<UserGroupRole> userGroupRoles)
107                    throws PortalException, SystemException {
108    
109                    return getUsersAdmin().filterUserGroupRoles(
110                            permissionChecker, userGroupRoles);
111            }
112    
113            public static List<UserGroup> filterUserGroups(
114                    PermissionChecker permissionChecker, List<UserGroup> userGroups) {
115    
116                    return getUsersAdmin().filterUserGroups(permissionChecker, userGroups);
117            }
118    
119            public static List<Address> getAddresses(ActionRequest actionRequest) {
120                    return getUsersAdmin().getAddresses(actionRequest);
121            }
122    
123            public static List<Address> getAddresses(
124                    ActionRequest actionRequest, List<Address> defaultAddresses) {
125    
126                    return getUsersAdmin().getAddresses(actionRequest, defaultAddresses);
127            }
128    
129            public static List<EmailAddress> getEmailAddresses(
130                    ActionRequest actionRequest) {
131    
132                    return getUsersAdmin().getEmailAddresses(actionRequest);
133            }
134    
135            public static List<EmailAddress> getEmailAddresses(
136                    ActionRequest actionRequest, List<EmailAddress> defaultEmailAddresses) {
137    
138                    return getUsersAdmin().getEmailAddresses(
139                            actionRequest, defaultEmailAddresses);
140            }
141    
142            public static OrderByComparator getGroupOrderByComparator(
143                    String orderByCol, String orderByType) {
144    
145                    return getUsersAdmin().getGroupOrderByComparator(
146                            orderByCol, orderByType);
147            }
148    
149            public static Long[] getOrganizationIds(List<Organization> organizations) {
150                    return getUsersAdmin().getOrganizationIds(organizations);
151            }
152    
153            public static OrderByComparator getOrganizationOrderByComparator(
154                    String orderByCol, String orderByType) {
155    
156                    return getUsersAdmin().getOrganizationOrderByComparator(
157                            orderByCol, orderByType);
158            }
159    
160            public static Tuple getOrganizations(Hits hits)
161                    throws PortalException, SystemException {
162    
163                    return getUsersAdmin().getOrganizations(hits);
164            }
165    
166            public static List<OrgLabor> getOrgLabors(ActionRequest actionRequest) {
167                    return getUsersAdmin().getOrgLabors(actionRequest);
168            }
169    
170            public static List<Phone> getPhones(ActionRequest actionRequest) {
171                    return getUsersAdmin().getPhones(actionRequest);
172            }
173    
174            public static List<Phone> getPhones(
175                    ActionRequest actionRequest, List<Phone> defaultPhones) {
176    
177                    return getUsersAdmin().getPhones(actionRequest, defaultPhones);
178            }
179    
180            public static OrderByComparator getRoleOrderByComparator(
181                    String orderByCol, String orderByType) {
182    
183                    return getUsersAdmin().getRoleOrderByComparator(
184                            orderByCol, orderByType);
185            }
186    
187            public static OrderByComparator getUserGroupOrderByComparator(
188                    String orderByCol, String orderByType) {
189    
190                    return getUsersAdmin().getUserGroupOrderByComparator(
191                            orderByCol, orderByType);
192            }
193    
194            public static List<UserGroupRole> getUserGroupRoles(
195                            PortletRequest portletRequest)
196                    throws PortalException, SystemException {
197    
198                    return getUsersAdmin().getUserGroupRoles(portletRequest);
199            }
200    
201            public static OrderByComparator getUserOrderByComparator(
202                    String orderByCol, String orderByType) {
203    
204                    return getUsersAdmin().getUserOrderByComparator(
205                            orderByCol, orderByType);
206            }
207    
208            public static Tuple getUsers(Hits hits)
209                    throws PortalException, SystemException {
210    
211                    return getUsersAdmin().getUsers(hits);
212            }
213    
214            public static UsersAdmin getUsersAdmin() {
215                    PortalRuntimePermission.checkGetBeanProperty(UsersAdminUtil.class);
216    
217                    return _usersAdmin;
218            }
219    
220            public static List<Website> getWebsites(ActionRequest actionRequest) {
221                    return getUsersAdmin().getWebsites(actionRequest);
222            }
223    
224            public static List<Website> getWebsites(
225                    ActionRequest actionRequest, List<Website> defaultWebsites) {
226    
227                    return getUsersAdmin().getWebsites(actionRequest, defaultWebsites);
228            }
229    
230            public static boolean hasUpdateEmailAddress(
231                            PermissionChecker permissionChecker, User user)
232                    throws PortalException, SystemException {
233    
234                    return getUsersAdmin().hasUpdateEmailAddress(permissionChecker, user);
235            }
236    
237            public static boolean hasUpdateScreenName(
238                            PermissionChecker permissionChecker, User user)
239                    throws PortalException, SystemException {
240    
241                    return getUsersAdmin().hasUpdateScreenName(permissionChecker, user);
242            }
243    
244            public static long[] removeRequiredRoles(long userId, long[] roleIds)
245                    throws PortalException, SystemException {
246    
247                    return getUsersAdmin().removeRequiredRoles(userId, roleIds);
248            }
249    
250            public static long[] removeRequiredRoles(User user, long[] roleIds)
251                    throws PortalException, SystemException {
252    
253                    return getUsersAdmin().removeRequiredRoles(user, roleIds);
254            }
255    
256            public static void updateAddresses(
257                            String className, long classPK, List<Address> addresses)
258                    throws PortalException, SystemException {
259    
260                    getUsersAdmin().updateAddresses(className, classPK, addresses);
261            }
262    
263            public static void updateEmailAddresses(
264                            String className, long classPK, List<EmailAddress> emailAddresses)
265                    throws PortalException, SystemException {
266    
267                    getUsersAdmin().updateEmailAddresses(
268                            className, classPK, emailAddresses);
269            }
270    
271            public static void updateOrgLabors(long classPK, List<OrgLabor> orgLabors)
272                    throws PortalException, SystemException {
273    
274                    getUsersAdmin().updateOrgLabors(classPK, orgLabors);
275            }
276    
277            public static void updatePhones(
278                            String className, long classPK, List<Phone> phones)
279                    throws PortalException, SystemException {
280    
281                    getUsersAdmin().updatePhones(className, classPK, phones);
282            }
283    
284            public static void updateWebsites(
285                            String className, long classPK, List<Website> websites)
286                    throws PortalException, SystemException {
287    
288                    getUsersAdmin().updateWebsites(className, classPK, websites);
289            }
290    
291            public void setUsersAdmin(UsersAdmin usersAdmin) {
292                    PortalRuntimePermission.checkSetBeanProperty(getClass());
293    
294                    _usersAdmin = usersAdmin;
295            }
296    
297            private static UsersAdmin _usersAdmin;
298    
299    }