001    /**
002     * Copyright (c) 2000-2010 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.enterpriseadmin.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.OrderByComparator;
020    import com.liferay.portal.model.Address;
021    import com.liferay.portal.model.EmailAddress;
022    import com.liferay.portal.model.Group;
023    import com.liferay.portal.model.OrgLabor;
024    import com.liferay.portal.model.Organization;
025    import com.liferay.portal.model.Phone;
026    import com.liferay.portal.model.Role;
027    import com.liferay.portal.model.User;
028    import com.liferay.portal.model.UserGroup;
029    import com.liferay.portal.model.UserGroupRole;
030    import com.liferay.portal.model.Website;
031    import com.liferay.portal.security.permission.PermissionChecker;
032    
033    import java.util.List;
034    
035    import javax.portlet.ActionRequest;
036    import javax.portlet.PortletRequest;
037    import javax.portlet.RenderResponse;
038    
039    import javax.servlet.http.HttpServletRequest;
040    
041    /**
042     * @author Brian Wing Shun Chan
043     * @author Jorge Ferrer
044     * @author Julio Camarero
045     */
046    public class EnterpriseAdminUtil {
047    
048            public static final String CUSTOM_QUESTION = "write-my-own-question";
049    
050            public static void addPortletBreadcrumbEntries(
051                            Organization organization, HttpServletRequest request,
052                            RenderResponse renderResponse)
053                    throws Exception {
054    
055                    getEnterpriseAdmin().addPortletBreadcrumbEntries(
056                            organization, request, renderResponse);
057            }
058    
059            public static String getCssClassName(Role role) {
060                    return getEnterpriseAdmin().getCssClassName(role);
061            }
062    
063            public static long[] addRequiredRoles(long userId, long[] roleIds)
064                    throws PortalException, SystemException {
065    
066                    return getEnterpriseAdmin().addRequiredRoles(userId, roleIds);
067            }
068    
069            public static long[] addRequiredRoles(User user, long[] roleIds)
070                    throws PortalException, SystemException {
071    
072                    return getEnterpriseAdmin().addRequiredRoles(user, roleIds);
073            }
074    
075            public static List<Role> filterGroupRoles(
076                            PermissionChecker permissionChecker, long groupId, List<Role> roles)
077                    throws PortalException, SystemException {
078    
079                    return getEnterpriseAdmin().filterGroupRoles(
080                            permissionChecker, groupId, roles);
081            }
082    
083            public static List<Group> filterGroups(
084                            PermissionChecker permissionChecker, List<Group> groups)
085                    throws PortalException, SystemException {
086    
087                    return getEnterpriseAdmin().filterGroups(permissionChecker, groups);
088            }
089    
090            public static List<Organization> filterOrganizations(
091                            PermissionChecker permissionChecker,
092                            List<Organization> organizations)
093                    throws PortalException, SystemException {
094    
095                    return getEnterpriseAdmin().filterOrganizations(
096                            permissionChecker, organizations);
097            }
098    
099            public static List<Role> filterRoles(
100                    PermissionChecker permissionChecker, List<Role> roles) {
101    
102                    return getEnterpriseAdmin().filterRoles(permissionChecker, roles);
103            }
104    
105            public static List<UserGroupRole> filterUserGroupRoles(
106                            PermissionChecker permissionChecker,
107                            List<UserGroupRole> userGroupRoles)
108                    throws PortalException, SystemException {
109    
110                    return getEnterpriseAdmin().filterUserGroupRoles(
111                            permissionChecker, userGroupRoles);
112            }
113    
114            public static List<UserGroup> filterUserGroups(
115                    PermissionChecker permissionChecker, List<UserGroup> userGroups) {
116    
117                    return getEnterpriseAdmin().filterUserGroups(
118                            permissionChecker, userGroups);
119            }
120    
121            public static List<Address> getAddresses(ActionRequest actionRequest) {
122                    return getEnterpriseAdmin().getAddresses(actionRequest);
123            }
124    
125            public static List<EmailAddress> getEmailAddresses(
126                    ActionRequest actionRequest) {
127    
128                    return getEnterpriseAdmin().getEmailAddresses(actionRequest);
129            }
130    
131            public static OrderByComparator getGroupOrderByComparator(
132                    String orderByCol, String orderByType) {
133    
134                    return getEnterpriseAdmin().getGroupOrderByComparator(
135                            orderByCol, orderByType);
136            }
137    
138            public static Long[][] getLeftAndRightOrganizationIds(long organizationId)
139                    throws PortalException, SystemException {
140    
141                    return getEnterpriseAdmin().getLeftAndRightOrganizationIds(
142                            organizationId);
143            }
144    
145            public static Long[][] getLeftAndRightOrganizationIds(
146                    Organization organization) {
147    
148                    return getEnterpriseAdmin().getLeftAndRightOrganizationIds(
149                            organization);
150            }
151    
152            public static Long[][] getLeftAndRightOrganizationIds(
153                    List<Organization> organizations) {
154    
155                    return getEnterpriseAdmin().getLeftAndRightOrganizationIds(
156                            organizations);
157            }
158    
159            public static Long[] getOrganizationIds(List<Organization> organizations) {
160                    return getEnterpriseAdmin().getOrganizationIds(organizations);
161            }
162    
163            public static OrderByComparator getOrganizationOrderByComparator(
164                    String orderByCol, String orderByType) {
165    
166                    return getEnterpriseAdmin().getOrganizationOrderByComparator(
167                            orderByCol, orderByType);
168            }
169    
170            public static List<OrgLabor> getOrgLabors(ActionRequest actionRequest) {
171                    return getEnterpriseAdmin().getOrgLabors(actionRequest);
172            }
173    
174            public static OrderByComparator getPasswordPolicyOrderByComparator(
175                    String orderByCol, String orderByType) {
176    
177                    return getEnterpriseAdmin().getPasswordPolicyOrderByComparator(
178                            orderByCol, orderByType);
179            }
180    
181            public static List<Phone> getPhones(ActionRequest actionRequest) {
182                    return getEnterpriseAdmin().getPhones(actionRequest);
183            }
184    
185            public static OrderByComparator getRoleOrderByComparator(
186                    String orderByCol, String orderByType) {
187    
188                    return getEnterpriseAdmin().getRoleOrderByComparator(
189                            orderByCol, orderByType);
190            }
191    
192            public static OrderByComparator getUserGroupOrderByComparator(
193                    String orderByCol, String orderByType) {
194    
195                    return getEnterpriseAdmin().getUserGroupOrderByComparator(
196                            orderByCol, orderByType);
197            }
198    
199            public static List<UserGroupRole> getUserGroupRoles(
200                            PortletRequest portletRequest)
201                    throws SystemException, PortalException {
202    
203                    return getEnterpriseAdmin().getUserGroupRoles(portletRequest);
204            }
205    
206            public static OrderByComparator getUserOrderByComparator(
207                    String orderByCol, String orderByType) {
208    
209                    return getEnterpriseAdmin().getUserOrderByComparator(
210                            orderByCol, orderByType);
211            }
212    
213            public static List<Website> getWebsites(ActionRequest actionRequest) {
214                    return getEnterpriseAdmin().getWebsites(actionRequest);
215            }
216    
217            public static boolean hasUpdateEmailAddress(
218                            PermissionChecker permissionChecker, User user)
219                    throws PortalException, SystemException {
220    
221                    return getEnterpriseAdmin().hasUpdateEmailAddress(
222                            permissionChecker, user);
223            }
224    
225            public static boolean hasUpdateScreenName(
226                            PermissionChecker permissionChecker, User user)
227                    throws PortalException, SystemException {
228    
229                    return getEnterpriseAdmin().hasUpdateScreenName(
230                            permissionChecker, user);
231            }
232    
233            public static long[] removeRequiredRoles(long userId, long[] roleIds)
234                    throws PortalException, SystemException {
235    
236                    return getEnterpriseAdmin().removeRequiredRoles(userId, roleIds);
237            }
238    
239            public static long[] removeRequiredRoles(User user, long[] roleIds)
240                    throws PortalException, SystemException {
241    
242                    return getEnterpriseAdmin().removeRequiredRoles(user, roleIds);
243            }
244    
245            public static void updateAddresses(
246                            String className, long classPK, List<Address> addresses)
247                    throws PortalException, SystemException {
248    
249                    getEnterpriseAdmin().updateAddresses(className, classPK, addresses);
250            }
251    
252            public static void updateEmailAddresses(
253                            String className, long classPK, List<EmailAddress> emailAddresses)
254                    throws PortalException, SystemException {
255    
256                    getEnterpriseAdmin().updateEmailAddresses(
257                            className, classPK, emailAddresses);
258            }
259    
260            public static void updateOrgLabors(long classPK, List<OrgLabor> orgLabors)
261                    throws PortalException, SystemException {
262    
263                    getEnterpriseAdmin().updateOrgLabors(classPK, orgLabors);
264            }
265    
266            public static void updatePhones(
267                            String className, long classPK, List<Phone> phones)
268                    throws PortalException, SystemException {
269    
270                    getEnterpriseAdmin().updatePhones(className, classPK, phones);
271            }
272    
273            public static void updateWebsites(
274                            String className, long classPK, List<Website> websites)
275                    throws PortalException, SystemException {
276    
277                    getEnterpriseAdmin().updateWebsites(className, classPK, websites);
278            }
279    
280            public static EnterpriseAdmin getEnterpriseAdmin() {
281                    return _enterpriseAdmin;
282            }
283    
284            public void setEnterpriseAdmin(EnterpriseAdmin enterpriseAdmin) {
285                    _enterpriseAdmin = enterpriseAdmin;
286            }
287    
288            private static EnterpriseAdmin _enterpriseAdmin;
289    
290    }