001    /**
002     * Copyright (c) 2000-2011 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.portal.service;
016    
017    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.util.MethodCache;
019    import com.liferay.portal.kernel.util.ReferenceRegistry;
020    
021    /**
022     * The utility for the group remote service. This utility wraps {@link com.liferay.portal.service.impl.GroupServiceImpl} and is the primary access point for service operations in application layer code running on a remote server.
023     *
024     * <p>
025     * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS credentials because this service can be accessed remotely.
026     * </p>
027     *
028     * @author Brian Wing Shun Chan
029     * @see GroupService
030     * @see com.liferay.portal.service.base.GroupServiceBaseImpl
031     * @see com.liferay.portal.service.impl.GroupServiceImpl
032     * @generated
033     */
034    public class GroupServiceUtil {
035            /*
036             * NOTE FOR DEVELOPERS:
037             *
038             * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.GroupServiceImpl} and rerun ServiceBuilder to regenerate this class.
039             */
040    
041            /**
042            * Adds a group.
043            *
044            * @param liveGroupId the primary key of the live group
045            * @param name the entity's name
046            * @param description the group's description (optionally
047            <code>null</code>)
048            * @param type the group's type. For more information see {@link
049            com.liferay.portal.model.GroupConstants}
050            * @param friendlyURL the group's friendlyURL (optionally
051            <code>null</code>)
052            * @param site whether the group is to be associated with a main site
053            * @param active whether the group is active
054            * @param serviceContext the service context to be applied (optionally
055            <code>null</code>). Can specify the group's asset category IDs,
056            asset tag names, and whether the group is for staging
057            * @return the group
058            * @throws PortalException if the user did not have permission to add the
059            group, if a creator could not be found, if the group's
060            information was invalid, if a layout could not be found, or if a
061            valid friendly URL could not be created for the group
062            * @throws SystemException if a system exception occurred
063            */
064            public static com.liferay.portal.model.Group addGroup(long liveGroupId,
065                    java.lang.String name, java.lang.String description, int type,
066                    java.lang.String friendlyURL, boolean site, boolean active,
067                    com.liferay.portal.service.ServiceContext serviceContext)
068                    throws com.liferay.portal.kernel.exception.PortalException,
069                            com.liferay.portal.kernel.exception.SystemException {
070                    return getService()
071                                       .addGroup(liveGroupId, name, description, type, friendlyURL,
072                            site, active, serviceContext);
073            }
074    
075            /**
076            * Adds the group using the group default live group ID.
077            *
078            * @param name the entity's name
079            * @param description the group's description (optionally
080            <code>null</code>)
081            * @param type the group's type. For more information see {@link
082            com.liferay.portal.model.GroupConstants}
083            * @param friendlyURL the group's friendlyURL
084            * @param site whether the group is to be associated with a main site
085            * @param active whether the group is active
086            * @param serviceContext the service context to be applied (optionally
087            <code>null</code>). Can specify the group's asset category IDs,
088            asset tag names, and whether the group is for staging
089            * @return the group
090            * @throws PortalException if the user did not have permission to add the
091            group, if a creator could not be found, if the group's
092            information was invalid, if a layout could not be found, or if a
093            valid friendly URL could not be created for the group
094            * @throws SystemException if a system exception occurred
095            */
096            public static com.liferay.portal.model.Group addGroup(
097                    java.lang.String name, java.lang.String description, int type,
098                    java.lang.String friendlyURL, boolean site, boolean active,
099                    com.liferay.portal.service.ServiceContext serviceContext)
100                    throws com.liferay.portal.kernel.exception.PortalException,
101                            com.liferay.portal.kernel.exception.SystemException {
102                    return getService()
103                                       .addGroup(name, description, type, friendlyURL, site,
104                            active, serviceContext);
105            }
106    
107            /**
108            * Adds the groups to the role.
109            *
110            * @param roleId the primary key of the role
111            * @param groupIds the primary keys of the groups
112            * @throws PortalException if the user did not have permission to update
113            the role
114            * @throws SystemException if a system exception occurred
115            */
116            public static void addRoleGroups(long roleId, long[] groupIds)
117                    throws com.liferay.portal.kernel.exception.PortalException,
118                            com.liferay.portal.kernel.exception.SystemException {
119                    getService().addRoleGroups(roleId, groupIds);
120            }
121    
122            /**
123            * Deletes the group.
124            *
125            * <p>
126            * The group is unstaged and its assets and resources including layouts,
127            * membership requests, subscriptions, teams, blogs, bookmarks, calendar
128            * events, image gallery, journals, message boards, polls, shopping related
129            * entities, software catalog, and wikis are also deleted.
130            * </p>
131            *
132            * @param groupId the primary key of the group
133            * @throws PortalException if the user did not have permission to delete
134            the group or its assets or resources, if a group with the
135            primary key could not be found, or if the group was a system
136            group
137            * @throws SystemException if a system exception occurred
138            */
139            public static void deleteGroup(long groupId)
140                    throws com.liferay.portal.kernel.exception.PortalException,
141                            com.liferay.portal.kernel.exception.SystemException {
142                    getService().deleteGroup(groupId);
143            }
144    
145            /**
146            * Returns the group with the primary key.
147            *
148            * @param groupId the primary key of the group
149            * @return the group with the primary key
150            * @throws PortalException if a group with the primary key could not be
151            found
152            * @throws SystemException if a system exception occurred
153            */
154            public static com.liferay.portal.model.Group getGroup(long groupId)
155                    throws com.liferay.portal.kernel.exception.PortalException,
156                            com.liferay.portal.kernel.exception.SystemException {
157                    return getService().getGroup(groupId);
158            }
159    
160            /**
161            * Returns the group with the name.
162            *
163            * @param companyId the primary key of the company
164            * @param name the group's name
165            * @return the group with the name
166            * @throws PortalException if a matching group could not be found
167            * @throws SystemException if a system exception occurred
168            */
169            public static com.liferay.portal.model.Group getGroup(long companyId,
170                    java.lang.String name)
171                    throws com.liferay.portal.kernel.exception.PortalException,
172                            com.liferay.portal.kernel.exception.SystemException {
173                    return getService().getGroup(companyId, name);
174            }
175    
176            /**
177            * Returns a range of all the site groups for which the user has control
178            * panel access.
179            *
180            * @param portlets the portlets to manage
181            * @param max the upper bound of the range of groups to consider (not
182            inclusive)
183            * @return the range of site groups for which the user has control panel
184            access
185            * @throws PortalException if a portal exception occurred
186            * @throws SystemException if a system exception occurred
187            */
188            public static java.util.List<com.liferay.portal.model.Group> getManageableSites(
189                    java.util.Collection<com.liferay.portal.model.Portlet> portlets, int max)
190                    throws com.liferay.portal.kernel.exception.PortalException,
191                            com.liferay.portal.kernel.exception.SystemException {
192                    return getService().getManageableSites(portlets, max);
193            }
194    
195            /**
196            * Returns the groups associated with the organizations.
197            *
198            * @param organizations the organizations
199            * @return the groups associated with the organizations
200            */
201            public static java.util.List<com.liferay.portal.model.Group> getOrganizationsGroups(
202                    java.util.List<com.liferay.portal.model.Organization> organizations) {
203                    return getService().getOrganizationsGroups(organizations);
204            }
205    
206            /**
207            * Returns the group associated with the user.
208            *
209            * @param companyId the primary key of the company
210            * @param userId the primary key of the user
211            * @return the group associated with the user
212            * @throws PortalException if a matching group could not be found
213            * @throws SystemException if a system exception occurred
214            */
215            public static com.liferay.portal.model.Group getUserGroup(long companyId,
216                    long userId)
217                    throws com.liferay.portal.kernel.exception.PortalException,
218                            com.liferay.portal.kernel.exception.SystemException {
219                    return getService().getUserGroup(companyId, userId);
220            }
221    
222            /**
223            * Returns the groups associated with the user groups.
224            *
225            * @param userGroups the user groups
226            * @return the groups associated with the user groups
227            * @throws PortalException if any one of the user group's group could not
228            be found
229            * @throws SystemException if a system exception occurred
230            */
231            public static java.util.List<com.liferay.portal.model.Group> getUserGroupsGroups(
232                    java.util.List<com.liferay.portal.model.UserGroup> userGroups)
233                    throws com.liferay.portal.kernel.exception.PortalException,
234                            com.liferay.portal.kernel.exception.SystemException {
235                    return getService().getUserGroupsGroups(userGroups);
236            }
237    
238            /**
239            * Returns the range of all groups associated with the user's organization
240            * groups, including the ancestors of the organization groups, unless
241            * portal property <code>organizations.membership.strict</code> is set to
242            * <code>true</code>.
243            *
244            * <p>
245            * Useful when paginating results. Returns a maximum of <code>end -
246            * start</code> instances. <code>start</code> and <code>end</code> are not
247            * primary keys, they are indexes in the result set. Thus, <code>0</code>
248            * refers to the first result in the set. Setting both <code>start</code>
249            * and <code>end</code> to {@link
250            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the
251            * full result set.
252            * </p>
253            *
254            * @param userId the primary key of the user
255            * @param start the lower bound of the range of groups to consider
256            * @param end the upper bound of the range of groups to consider (not
257            inclusive)
258            * @return the range of groups associated with the user's organizations
259            * @throws PortalException if a user with the primary key could not be
260            found or if another portal exception occurred
261            * @throws SystemException if a system exception occurred
262            */
263            public static java.util.List<com.liferay.portal.model.Group> getUserOrganizationsGroups(
264                    long userId, int start, int end)
265                    throws com.liferay.portal.kernel.exception.PortalException,
266                            com.liferay.portal.kernel.exception.SystemException {
267                    return getService().getUserOrganizationsGroups(userId, start, end);
268            }
269    
270            /**
271            * Returns the guest or current user's layout set group, organization
272            * groups, inherited organization groups, and site groups.
273            *
274            * @return the user's layout set group, organization groups, and inherited
275            organization groups, and site groups
276            * @throws PortalException if a portal exception occurred
277            * @throws SystemException if a system exception occurred
278            */
279            public static java.util.List<com.liferay.portal.model.Group> getUserSites()
280                    throws com.liferay.portal.kernel.exception.PortalException,
281                            com.liferay.portal.kernel.exception.SystemException {
282                    return getService().getUserSites();
283            }
284    
285            /**
286            * Returns the guest or current user's group &quot;places&quot; associated
287            * with the group entity class names, including the control panel group if
288            * the user is permitted to view the control panel.
289            *
290            * <p>
291            * <ul> <li> Class name &quot;User&quot; includes the user's layout set
292            * group. </li> <li> Class name &quot;Organization&quot; includes the
293            * user's immediate organization groups and inherited organization groups.
294            * </li> <li> Class name &quot;Group&quot; includes the user's immediate
295            * organization groups and site groups. </li> <li> A
296            * <code>classNames</code> value of <code>null</code> includes the user's
297            * layout set group, organization groups, inherited organization groups,
298            * and site groups. </li> </ul>
299            * </p>
300            *
301            * @param classNames the group entity class names (optionally
302            <code>null</code>). For more information see {@link
303            #getUserPlaces(String[], int)}
304            * @param max the maximum number of groups to return
305            * @return the user's group &quot;places&quot;
306            * @throws PortalException if a portal exception occurred
307            * @throws SystemException if a system exception occurred
308            */
309            public static java.util.List<com.liferay.portal.model.Group> getUserPlaces(
310                    java.lang.String[] classNames, int max)
311                    throws com.liferay.portal.kernel.exception.PortalException,
312                            com.liferay.portal.kernel.exception.SystemException {
313                    return getService().getUserPlaces(classNames, max);
314            }
315    
316            /**
317            * Returns the user's group &quot;places&quot; associated with the group
318            * entity class names, including the control panel group if the user is
319            * permitted to view the control panel.
320            *
321            * <p>
322            * <ul> <li> Class name &quot;User&quot; includes the user's layout set
323            * group. </li> <li> Class name &quot;Organization&quot; includes the
324            * user's immediate organization groups and inherited organization groups.
325            * </li> <li> Class name &quot;Group&quot; includes the user's immediate
326            * organization groups and site groups. </li> <li> A
327            * <code>classNames</code> value of <code>null</code> includes the user's
328            * layout set group, organization groups, inherited organization groups,
329            * and site groups. </li> </ul>
330            * </p>
331            *
332            * @param userId the primary key of the user
333            * @param classNames the group entity class names (optionally
334            <code>null</code>). For more information see {@link
335            #getUserPlaces(long, String[], int)}
336            * @param max the maximum number of groups to return
337            * @return the user's group &quot;places&quot;
338            * @throws PortalException if a portal exception occurred
339            * @throws SystemException if a system exception occurred
340            */
341            public static java.util.List<com.liferay.portal.model.Group> getUserPlaces(
342                    long userId, java.lang.String[] classNames, int max)
343                    throws com.liferay.portal.kernel.exception.PortalException,
344                            com.liferay.portal.kernel.exception.SystemException {
345                    return getService().getUserPlaces(userId, classNames, max);
346            }
347    
348            /**
349            * Returns <code>true</code> if the user is associated with the group,
350            * including the user's inherited organizations and user groups. System and
351            * staged groups are not included.
352            *
353            * @param userId the primary key of the user
354            * @param groupId the primary key of the group
355            * @return <code>true</code> if the user is associated with the group;
356            <code>false</code> otherwise
357            * @throws SystemException if a system exception occurred
358            */
359            public static boolean hasUserGroup(long userId, long groupId)
360                    throws com.liferay.portal.kernel.exception.SystemException {
361                    return getService().hasUserGroup(userId, groupId);
362            }
363    
364            /**
365            * Returns a name ordered range of all the site groups and organization
366            * groups that match the name and description, optionally including the
367            * user's inherited organization groups and user groups. System and staged
368            * groups are not included.
369            *
370            * <p>
371            * Useful when paginating results. Returns a maximum of <code>end -
372            * start</code> instances. <code>start</code> and <code>end</code> are not
373            * primary keys, they are indexes in the result set. Thus, <code>0</code>
374            * refers to the first result in the set. Setting both <code>start</code>
375            * and <code>end</code> to {@link
376            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the
377            * full result set.
378            * </p>
379            *
380            * @param companyId the primary key of the company
381            * @param name the group's name (optionally <code>null</code>)
382            * @param description the group's description (optionally
383            <code>null</code>)
384            * @param params the finder params (optionally <code>null</code>). To
385            include the user's inherited organizations and user groups in
386            the search, add entries having &quot;usersGroups&quot; and
387            &quot;inherit&quot; as keys mapped to the the user's ID. For
388            more information see {@link
389            com.liferay.portal.service.persistence.GroupFinder}
390            * @param start the lower bound of the range of groups to return
391            * @param end the upper bound of the range of groups to return (not
392            inclusive)
393            * @return the matching groups ordered by name
394            * @throws SystemException if a system exception occurred
395            */
396            public static java.util.List<com.liferay.portal.model.Group> search(
397                    long companyId, java.lang.String name, java.lang.String description,
398                    java.lang.String[] params, int start, int end)
399                    throws com.liferay.portal.kernel.exception.SystemException {
400                    return getService()
401                                       .search(companyId, name, description, params, start, end);
402            }
403    
404            /**
405            * Returns the number of groups and organization groups that match the name
406            * and description, optionally including the user's inherited organizations
407            * and user groups. System and staged groups are not included.
408            *
409            * @param companyId the primary key of the company
410            * @param name the group's name (optionally <code>null</code>)
411            * @param description the group's description (optionally
412            <code>null</code>)
413            * @param params the finder params (optionally <code>null</code>). To
414            include the user's inherited organizations and user groups in
415            the search, add entries having &quot;usersGroups&quot; and
416            &quot;inherit&quot; as keys mapped to the the user's ID. For
417            more information see {@link
418            com.liferay.portal.service.persistence.GroupFinder}
419            * @return the number of matching groups
420            * @throws SystemException if a system exception occurred
421            */
422            public static int searchCount(long companyId, java.lang.String name,
423                    java.lang.String description, java.lang.String[] params)
424                    throws com.liferay.portal.kernel.exception.SystemException {
425                    return getService().searchCount(companyId, name, description, params);
426            }
427    
428            /**
429            * Sets the groups associated with the role, removing and adding
430            * associations as necessary.
431            *
432            * @param roleId the primary key of the role
433            * @param groupIds the primary keys of the groups
434            * @throws PortalException if the user did not have permission to update
435            update the role
436            * @throws SystemException if a system exception occurred
437            */
438            public static void setRoleGroups(long roleId, long[] groupIds)
439                    throws com.liferay.portal.kernel.exception.PortalException,
440                            com.liferay.portal.kernel.exception.SystemException {
441                    getService().setRoleGroups(roleId, groupIds);
442            }
443    
444            /**
445            * Removes the groups from the role.
446            *
447            * @param roleId the primary key of the role
448            * @param groupIds the primary keys of the groups
449            * @throws PortalException if the user did not have permission to update
450            the role
451            * @throws SystemException if a system exception occurred
452            */
453            public static void unsetRoleGroups(long roleId, long[] groupIds)
454                    throws com.liferay.portal.kernel.exception.PortalException,
455                            com.liferay.portal.kernel.exception.SystemException {
456                    getService().unsetRoleGroups(roleId, groupIds);
457            }
458    
459            /**
460            * Updates the group's friendly URL.
461            *
462            * @param groupId the primary key of the group
463            * @param friendlyURL the group's new friendlyURL (optionally
464            <code>null</code>)
465            * @return the group
466            * @throws PortalException if the user did not have permission to update
467            the group, if a group with the primary key could not be found,
468            or if a valid friendly URL could not be created for the group
469            * @throws SystemException if a system exception occurred
470            */
471            public static com.liferay.portal.model.Group updateFriendlyURL(
472                    long groupId, java.lang.String friendlyURL)
473                    throws com.liferay.portal.kernel.exception.PortalException,
474                            com.liferay.portal.kernel.exception.SystemException {
475                    return getService().updateFriendlyURL(groupId, friendlyURL);
476            }
477    
478            /**
479            * Updates the group's type settings.
480            *
481            * @param groupId the primary key of the group
482            * @param typeSettings the group's new type settings (optionally
483            <code>null</code>)
484            * @return the group
485            * @throws PortalException if the user did not have permission to update
486            the group or if a group with the primary key could not be found
487            * @throws SystemException if a system exception occurred
488            */
489            public static com.liferay.portal.model.Group updateGroup(long groupId,
490                    java.lang.String typeSettings)
491                    throws com.liferay.portal.kernel.exception.PortalException,
492                            com.liferay.portal.kernel.exception.SystemException {
493                    return getService().updateGroup(groupId, typeSettings);
494            }
495    
496            /**
497            * Updates the group.
498            *
499            * @param groupId the primary key of the group
500            * @param name the group's new name
501            * @param description the group's new description (optionally
502            <code>null</code>)
503            * @param type the group's new type. For more information see {@link
504            com.liferay.portal.model.GroupConstants}
505            * @param friendlyURL the group's new friendlyURL (optionally
506            <code>null</code>)
507            * @param active whether the group is active
508            * @param serviceContext the service context to be applied (optionally
509            <code>null</code>). Can specify the group's replacement asset
510            category IDs and replacement asset tag names
511            * @return the group
512            * @throws PortalException if the user did not have permission to update
513            the group, if a group with the primary key could not be found,
514            if the friendly URL was invalid or could one not be created
515            * @throws SystemException if a system exception occurred
516            */
517            public static com.liferay.portal.model.Group updateGroup(long groupId,
518                    java.lang.String name, java.lang.String description, int type,
519                    java.lang.String friendlyURL, boolean active,
520                    com.liferay.portal.service.ServiceContext serviceContext)
521                    throws com.liferay.portal.kernel.exception.PortalException,
522                            com.liferay.portal.kernel.exception.SystemException {
523                    return getService()
524                                       .updateGroup(groupId, name, description, type, friendlyURL,
525                            active, serviceContext);
526            }
527    
528            public static GroupService getService() {
529                    if (_service == null) {
530                            _service = (GroupService)PortalBeanLocatorUtil.locate(GroupService.class.getName());
531    
532                            ReferenceRegistry.registerReference(GroupServiceUtil.class,
533                                    "_service");
534                            MethodCache.remove(GroupService.class);
535                    }
536    
537                    return _service;
538            }
539    
540            public void setService(GroupService service) {
541                    MethodCache.remove(GroupService.class);
542    
543                    _service = service;
544    
545                    ReferenceRegistry.registerReference(GroupServiceUtil.class, "_service");
546                    MethodCache.remove(GroupService.class);
547            }
548    
549            private static GroupService _service;
550    }