001 /** 002 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. 003 * 004 * The contents of this file are subject to the terms of the Liferay Enterprise 005 * Subscription License ("License"). You may not use this file except in 006 * compliance with the License. You can obtain a copy of the License by 007 * contacting Liferay, Inc. See the License for the specific language governing 008 * permissions and limitations under the License, including but not limited to 009 * distribution rights of the Software. 010 * 011 * 012 * 013 */ 014 015 package com.liferay.portal.service.impl; 016 017 import com.liferay.portal.kernel.dao.orm.QueryUtil; 018 import com.liferay.portal.kernel.exception.PortalException; 019 import com.liferay.portal.kernel.exception.SystemException; 020 import com.liferay.portal.kernel.util.ArrayUtil; 021 import com.liferay.portal.kernel.util.ListUtil; 022 import com.liferay.portal.kernel.util.MapUtil; 023 import com.liferay.portal.kernel.util.UniqueList; 024 import com.liferay.portal.model.Group; 025 import com.liferay.portal.model.GroupConstants; 026 import com.liferay.portal.model.Organization; 027 import com.liferay.portal.model.Portlet; 028 import com.liferay.portal.model.User; 029 import com.liferay.portal.model.UserGroup; 030 import com.liferay.portal.security.auth.PrincipalException; 031 import com.liferay.portal.security.permission.ActionKeys; 032 import com.liferay.portal.security.permission.PermissionChecker; 033 import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil; 034 import com.liferay.portal.service.ServiceContext; 035 import com.liferay.portal.service.base.GroupServiceBaseImpl; 036 import com.liferay.portal.service.permission.GroupPermissionUtil; 037 import com.liferay.portal.service.permission.PortalPermissionUtil; 038 import com.liferay.portal.service.permission.PortletPermissionUtil; 039 import com.liferay.portal.service.permission.RolePermissionUtil; 040 import com.liferay.portal.service.permission.UserPermissionUtil; 041 import com.liferay.portal.util.PropsValues; 042 043 import java.util.ArrayList; 044 import java.util.Collection; 045 import java.util.Collections; 046 import java.util.Iterator; 047 import java.util.LinkedHashMap; 048 import java.util.List; 049 050 /** 051 * The group remote service is responsible for accessing, creating, modifying 052 * and deleting groups. For more information on group services and Group, see 053 * {@link com.liferay.portal.service.impl.GroupLocalServiceImpl}. 054 * 055 * @author Brian Wing Shun Chan 056 */ 057 public class GroupServiceImpl extends GroupServiceBaseImpl { 058 059 /** 060 * Adds a group. 061 * 062 * @param liveGroupId the primary key of the live group 063 * @param name the entity's name 064 * @param description the group's description (optionally 065 * <code>null</code>) 066 * @param type the group's type. For more information see {@link 067 * com.liferay.portal.model.GroupConstants} 068 * @param friendlyURL the group's friendlyURL (optionally 069 * <code>null</code>) 070 * @param site whether the group is to be associated with a main site 071 * @param active whether the group is active 072 * @param serviceContext the service context to be applied (optionally 073 * <code>null</code>). Can set the asset category IDs and asset tag 074 * names for the group, and can set whether the group is for staging 075 * @return the group 076 * @throws PortalException if the user did not have permission to add the 077 * group, if a creator could not be found, if the group's 078 * information was invalid, if a layout could not be found, or if a 079 * valid friendly URL could not be created for the group 080 * @throws SystemException if a system exception occurred 081 */ 082 public Group addGroup( 083 long liveGroupId, String name, String description, int type, 084 String friendlyURL, boolean site, boolean active, 085 ServiceContext serviceContext) 086 throws PortalException, SystemException { 087 088 GroupPermissionUtil.check( 089 getPermissionChecker(), liveGroupId, ActionKeys.UPDATE); 090 091 return groupLocalService.addGroup( 092 getUserId(), null, 0, liveGroupId, name, description, type, 093 friendlyURL, site, active, serviceContext); 094 } 095 096 /** 097 * Adds the group using the group default live group ID. 098 * 099 * @param name the entity's name 100 * @param description the group's description (optionally 101 * <code>null</code>) 102 * @param type the group's type. For more information see {@link 103 * com.liferay.portal.model.GroupConstants} 104 * @param friendlyURL the group's friendlyURL 105 * @param site whether the group is to be associated with a main site 106 * @param active whether the group is active 107 * @param serviceContext the service context to be applied (optionally 108 * <code>null</code>). Can set asset category IDs and asset tag 109 * names for the group, and can set whether the group is for staging 110 * @return the group 111 * @throws PortalException if the user did not have permission to add the 112 * group, if a creator could not be found, if the group's 113 * information was invalid, if a layout could not be found, or if a 114 * valid friendly URL could not be created for the group 115 * @throws SystemException if a system exception occurred 116 */ 117 public Group addGroup( 118 String name, String description, int type, String friendlyURL, 119 boolean site, boolean active, ServiceContext serviceContext) 120 throws PortalException, SystemException { 121 122 PortalPermissionUtil.check( 123 getPermissionChecker(), ActionKeys.ADD_COMMUNITY); 124 125 return groupLocalService.addGroup( 126 getUserId(), null, 0, name, description, type, friendlyURL, site, 127 active, serviceContext); 128 } 129 130 /** 131 * Adds the groups to the role. 132 * 133 * @param roleId the primary key of the role 134 * @param groupIds the primary keys of the groups 135 * @throws PortalException if the user did not have permission to update the 136 * role 137 * @throws SystemException if a system exception occurred 138 */ 139 public void addRoleGroups(long roleId, long[] groupIds) 140 throws PortalException, SystemException { 141 142 RolePermissionUtil.check( 143 getPermissionChecker(), roleId, ActionKeys.UPDATE); 144 145 groupLocalService.addRoleGroups(roleId, groupIds); 146 } 147 148 /** 149 * Deletes the group. 150 * 151 * <p> 152 * The group is unstaged and its assets and resources including layouts, 153 * membership requests, subscriptions, teams, blogs, bookmarks, calendar 154 * events, image gallery, journals, message boards, polls, shopping related 155 * entities, software catalog, and wikis are also deleted. 156 * </p> 157 * 158 * @param groupId the primary key of the group 159 * @throws PortalException if the user did not have permission to delete the 160 * group or its assets or resources, if a group with the primary key 161 * could not be found, or if the group was a system group 162 * @throws SystemException if a system exception occurred 163 */ 164 public void deleteGroup(long groupId) 165 throws PortalException, SystemException { 166 167 GroupPermissionUtil.check( 168 getPermissionChecker(), groupId, ActionKeys.DELETE); 169 170 groupLocalService.deleteGroup(groupId); 171 } 172 173 /** 174 * Returns the group with the primary key. 175 * 176 * @param groupId the primary key of the group 177 * @return the group with the primary key 178 * @throws PortalException if a group with the primary key could not be 179 * found or if the current user did not have permission to view the 180 * group 181 * @throws SystemException if a system exception occurred 182 */ 183 public Group getGroup(long groupId) 184 throws PortalException, SystemException { 185 186 GroupPermissionUtil.check( 187 getPermissionChecker(), groupId, ActionKeys.VIEW); 188 189 return groupLocalService.getGroup(groupId); 190 } 191 192 /** 193 * Returns the group with the name. 194 * 195 * @param companyId the primary key of the company 196 * @param name the group's name 197 * @return the group with the name 198 * @throws PortalException if a matching group could not be found or if the 199 * current user did not have permission to view the group 200 * @throws SystemException if a system exception occurred 201 */ 202 public Group getGroup(long companyId, String name) 203 throws PortalException, SystemException { 204 205 Group group = groupLocalService.getGroup(companyId, name); 206 207 GroupPermissionUtil.check( 208 getPermissionChecker(), group.getGroupId(), ActionKeys.VIEW); 209 210 return group; 211 } 212 213 /** 214 * Returns a range of all the site groups for which the user has control 215 * panel access. 216 * 217 * @param portlets the portlets to manage 218 * @param max the upper bound of the range of groups to consider (not 219 * inclusive) 220 * @return the range of site groups for which the user has control panel 221 * access 222 * @throws PortalException if a portal exception occurred 223 * @throws SystemException if a system exception occurred 224 */ 225 public List<Group> getManageableSites(Collection<Portlet> portlets, int max) 226 throws PortalException, SystemException { 227 228 PermissionChecker permissionChecker = getPermissionChecker(); 229 230 if (permissionChecker.isCompanyAdmin()) { 231 LinkedHashMap<String, Object> params = 232 new LinkedHashMap<String, Object>(); 233 234 params.put("site", Boolean.TRUE); 235 236 return groupLocalService.search( 237 permissionChecker.getCompanyId(), null, null, null, params, 0, 238 max); 239 } 240 241 List<Group> groups = new UniqueList<Group>(); 242 243 groups.addAll( 244 userPersistence.getGroups(permissionChecker.getUserId(), 0, max)); 245 groups.addAll( 246 getUserOrganizationsGroups(permissionChecker.getUserId(), 0, max)); 247 248 List<UserGroup> userGroups = userPersistence.getUserGroups( 249 permissionChecker.getUserId(), 0, max); 250 251 for (UserGroup userGroup : userGroups) { 252 groups.addAll( 253 userGroupPersistence.getGroups( 254 userGroup.getUserGroupId(), 0, max)); 255 } 256 257 Iterator<Group> itr = groups.iterator(); 258 259 while (itr.hasNext()) { 260 Group group = itr.next(); 261 262 if (!group.isSite() || 263 !PortletPermissionUtil.contains( 264 permissionChecker, group.getGroupId(), 0L, portlets, 265 ActionKeys.ACCESS_IN_CONTROL_PANEL)) { 266 267 itr.remove(); 268 } 269 } 270 271 return groups; 272 } 273 274 /** 275 * Returns the groups associated with the organizations. 276 * 277 * @param organizations the organizations 278 * @return the groups associated with the organizations 279 * @throws PortalException if a portal exception occurred 280 * @throws SystemException if a system exception occurred 281 */ 282 public List<Group> getOrganizationsGroups(List<Organization> organizations) 283 throws PortalException, SystemException { 284 285 List<Group> groups = groupLocalService.getOrganizationsGroups( 286 organizations); 287 288 return filterGroups(groups); 289 } 290 291 /** 292 * Returns the group associated with the user. 293 * 294 * @param companyId the primary key of the company 295 * @param userId the primary key of the user 296 * @return the group associated with the user 297 * @throws PortalException if a matching group could not be found or if the 298 * current user did not have permission to view the group 299 * @throws SystemException if a system exception occurred 300 */ 301 public Group getUserGroup(long companyId, long userId) 302 throws PortalException, SystemException { 303 304 Group group = groupLocalService.getUserGroup(companyId, userId); 305 306 GroupPermissionUtil.check( 307 getPermissionChecker(), group.getGroupId(), ActionKeys.VIEW); 308 309 return group; 310 } 311 312 /** 313 * Returns the groups associated with the user groups. 314 * 315 * @param userGroups the user groups 316 * @return the groups associated with the user groups 317 * @throws PortalException if any one of the user group's group could not be 318 * found 319 * @throws SystemException if a system exception occurred 320 */ 321 public List<Group> getUserGroupsGroups(List<UserGroup> userGroups) 322 throws PortalException, SystemException { 323 324 List<Group> groups = groupLocalService.getUserGroupsGroups(userGroups); 325 326 return filterGroups(groups); 327 } 328 329 /** 330 * Returns the range of all groups associated with the user's organization 331 * groups, including the ancestors of the organization groups, unless portal 332 * property <code>organizations.membership.strict</code> is set to 333 * <code>true</code>. 334 * 335 * <p> 336 * Useful when paginating results. Returns a maximum of <code>end - 337 * start</code> instances. <code>start</code> and <code>end</code> are not 338 * primary keys, they are indexes in the result set. Thus, <code>0</code> 339 * refers to the first result in the set. Setting both <code>start</code> 340 * and <code>end</code> to {@link 341 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 342 * result set. 343 * </p> 344 * 345 * @param userId the primary key of the user 346 * @param start the lower bound of the range of groups to consider 347 * @param end the upper bound of the range of groups to consider (not 348 * inclusive) 349 * @return the range of groups associated with the user's organizations 350 * @throws PortalException if a user with the primary key could not be found 351 * or if another portal exception occurred 352 * @throws SystemException if a system exception occurred 353 */ 354 public List<Group> getUserOrganizationsGroups( 355 long userId, int start, int end) 356 throws PortalException, SystemException { 357 358 List<Group> groups = groupLocalService.getUserOrganizationsGroups( 359 userId, start, end); 360 361 return filterGroups(groups); 362 } 363 364 public List<Group> getUserPlaces( 365 long userId, String[] classNames, boolean includeControlPanel, 366 int max) 367 throws PortalException, SystemException { 368 369 User user = userPersistence.fetchByPrimaryKey(userId); 370 371 if (user.isDefaultUser()) { 372 return Collections.emptyList(); 373 } 374 375 List<Group> userPlaces = new UniqueList<Group>(); 376 377 int start = QueryUtil.ALL_POS; 378 int end = QueryUtil.ALL_POS; 379 380 if (max != QueryUtil.ALL_POS) { 381 start = 0; 382 end = max; 383 } 384 385 if ((classNames == null) || 386 ArrayUtil.contains(classNames, Group.class.getName())) { 387 388 LinkedHashMap<String, Object> groupParams = 389 new LinkedHashMap<String, Object>(); 390 391 groupParams.put("active", Boolean.TRUE); 392 groupParams.put("usersGroups", new Long(userId)); 393 394 userPlaces.addAll( 395 groupLocalService.search( 396 user.getCompanyId(), groupParams, start, end)); 397 } 398 399 if ((classNames == null) || 400 ArrayUtil.contains(classNames, Organization.class.getName())) { 401 402 LinkedHashMap<String, Object> organizationParams = 403 new LinkedHashMap<String, Object>(); 404 405 organizationParams.put("usersOrgs", new Long(userId)); 406 407 List<Organization> userOrgs = organizationLocalService.search( 408 user.getCompanyId(), organizationParams, start, end); 409 410 for (Organization organization : userOrgs) { 411 userPlaces.add(0, organization.getGroup()); 412 413 if (!PropsValues.ORGANIZATIONS_MEMBERSHIP_STRICT) { 414 for (Organization ancestorOrganization : 415 organization.getAncestors()) { 416 417 userPlaces.add(0, ancestorOrganization.getGroup()); 418 } 419 } 420 } 421 } 422 423 if ((classNames == null) || 424 ArrayUtil.contains(classNames, User.class.getName())) { 425 426 if (PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_ENABLED || 427 PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_ENABLED) { 428 429 Group userGroup = user.getGroup(); 430 431 userPlaces.add(0, userGroup); 432 } 433 } 434 435 PermissionChecker permissionChecker = getPermissionChecker(); 436 437 if (permissionChecker.getUserId() != userId) { 438 try { 439 permissionChecker = PermissionCheckerFactoryUtil.create(user); 440 } 441 catch (Exception e) { 442 throw new PrincipalException(e); 443 } 444 } 445 446 if (includeControlPanel && 447 PortalPermissionUtil.contains( 448 permissionChecker, ActionKeys.VIEW_CONTROL_PANEL)) { 449 450 Group controlPanelGroup = groupLocalService.getGroup( 451 user.getCompanyId(), GroupConstants.CONTROL_PANEL); 452 453 userPlaces.add(0, controlPanelGroup); 454 } 455 456 if ((max != QueryUtil.ALL_POS) && (userPlaces.size() > max)) { 457 userPlaces = ListUtil.subList(userPlaces, start, end); 458 } 459 460 return Collections.unmodifiableList(userPlaces); 461 } 462 463 /** 464 * Returns the user's group "places" associated with the group 465 * entity class names, including the control panel group if the user is 466 * permitted to view the control panel. 467 * 468 * <p> 469 * <ul> <li> Class name "User" includes the user's layout set 470 * group. </li> <li> Class name "Organization" includes the user's 471 * immediate organization groups and inherited organization groups. </li> 472 * <li> Class name "Group" includes the user's immediate 473 * organization groups and site groups. </li> <li> A <code>classNames</code> 474 * value of <code>null</code> includes the user's layout set group, 475 * organization groups, inherited organization groups, and site groups. 476 * </li> </ul> 477 * </p> 478 * 479 * @param userId the primary key of the user 480 * @param classNames the group entity class names (optionally 481 * <code>null</code>). For more information see {@link 482 * #getUserPlaces(long, String[], int)} 483 * @param max the maximum number of groups to return 484 * @return the user's group "places" 485 * @throws PortalException if a portal exception occurred 486 * @throws SystemException if a system exception occurred 487 */ 488 public List<Group> getUserPlaces(long userId, String[] classNames, int max) 489 throws PortalException, SystemException { 490 491 return getUserPlaces(userId, classNames, false, max); 492 } 493 494 /** 495 * Returns the guest or current user's group "places" associated 496 * with the group entity class names, including the control panel group if 497 * the user is permitted to view the control panel. 498 * 499 * <p> 500 * <ul> <li> Class name "User" includes the user's layout set 501 * group. </li> <li> Class name "Organization" includes the user's 502 * immediate organization groups and inherited organization groups. </li> 503 * <li> Class name "Group" includes the user's immediate 504 * organization groups and site groups. </li> <li> A <code>classNames</code> 505 * value of <code>null</code> includes the user's layout set group, 506 * organization groups, inherited organization groups, and site groups. 507 * </li> </ul> 508 * </p> 509 * 510 * @param classNames the group entity class names (optionally 511 * <code>null</code>). For more information see {@link 512 * #getUserPlaces(String[], int)} 513 * @param max the maximum number of groups to return 514 * @return the user's group "places" 515 * @throws PortalException if a portal exception occurred 516 * @throws SystemException if a system exception occurred 517 */ 518 public List<Group> getUserPlaces(String[] classNames, int max) 519 throws PortalException, SystemException { 520 521 return getUserPlaces(getGuestOrUserId(), classNames, false, max); 522 } 523 524 /** 525 * Returns the guest or current user's layout set group, organization 526 * groups, inherited organization groups, and site groups. 527 * 528 * @return the user's layout set group, organization groups, and inherited 529 * organization groups, and site groups 530 * @throws PortalException if a portal exception occurred 531 * @throws SystemException if a system exception occurred 532 */ 533 public List<Group> getUserSites() throws PortalException, SystemException { 534 return getUserPlaces(null, QueryUtil.ALL_POS); 535 } 536 537 /** 538 * Returns <code>true</code> if the user is associated with the group, 539 * including the user's inherited organizations and user groups. System and 540 * staged groups are not included. 541 * 542 * @param userId the primary key of the user 543 * @param groupId the primary key of the group 544 * @return <code>true</code> if the user is associated with the group; 545 * <code>false</code> otherwise 546 * @throws SystemException if a system exception occurred 547 */ 548 public boolean hasUserGroup(long userId, long groupId) 549 throws PortalException, SystemException { 550 551 try { 552 UserPermissionUtil.check( 553 getPermissionChecker(), userId, ActionKeys.VIEW); 554 } 555 catch (PrincipalException e) { 556 GroupPermissionUtil.check( 557 getPermissionChecker(), groupId, ActionKeys.VIEW_MEMBERS); 558 } 559 560 return groupLocalService.hasUserGroup(userId, groupId); 561 } 562 563 /** 564 * Returns a name ordered range of all the site groups and organization 565 * groups that match the name and description, optionally including the 566 * user's inherited organization groups and user groups. System and staged 567 * groups are not included. 568 * 569 * <p> 570 * Useful when paginating results. Returns a maximum of <code>end - 571 * start</code> instances. <code>start</code> and <code>end</code> are not 572 * primary keys, they are indexes in the result set. Thus, <code>0</code> 573 * refers to the first result in the set. Setting both <code>start</code> 574 * and <code>end</code> to {@link 575 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 576 * result set. 577 * </p> 578 * 579 * @param companyId the primary key of the company 580 * @param name the group's name (optionally <code>null</code>) 581 * @param description the group's description (optionally 582 * <code>null</code>) 583 * @param params the finder params (optionally <code>null</code>). To 584 * include the user's inherited organizations and user groups in the 585 * search, add entries having "usersGroups" and 586 * "inherit" as keys mapped to the the user's ID. For more 587 * information see {@link 588 * com.liferay.portal.service.persistence.GroupFinder} 589 * @param start the lower bound of the range of groups to return 590 * @param end the upper bound of the range of groups to return (not 591 * inclusive) 592 * @return the matching groups ordered by name 593 * @throws PortalException if a portal exception occurred 594 * @throws SystemException if a system exception occurred 595 */ 596 public List<Group> search( 597 long companyId, String name, String description, String[] params, 598 int start, int end) 599 throws PortalException, SystemException { 600 601 LinkedHashMap<String, Object> paramsObj = MapUtil.toLinkedHashMap( 602 params); 603 604 List<Group> groups = groupLocalService.search( 605 companyId, name, description, paramsObj, start, end); 606 607 return filterGroups(groups); 608 } 609 610 /** 611 * Returns the number of groups and organization groups that match the name 612 * and description, optionally including the user's inherited organizations 613 * and user groups. System and staged groups are not included. 614 * 615 * @param companyId the primary key of the company 616 * @param name the group's name (optionally <code>null</code>) 617 * @param description the group's description (optionally 618 * <code>null</code>) 619 * @param params the finder params (optionally <code>null</code>). To 620 * include the user's inherited organizations and user groups in the 621 * search, add entries having "usersGroups" and 622 * "inherit" as keys mapped to the the user's ID. For more 623 * information see {@link 624 * com.liferay.portal.service.persistence.GroupFinder} 625 * @return the number of matching groups 626 * @throws SystemException if a system exception occurred 627 */ 628 public int searchCount( 629 long companyId, String name, String description, String[] params) 630 throws SystemException { 631 632 LinkedHashMap<String, Object> paramsObj = MapUtil.toLinkedHashMap( 633 params); 634 635 return groupLocalService.searchCount( 636 companyId, name, description, paramsObj); 637 } 638 639 /** 640 * Sets the groups associated with the role, removing and adding 641 * associations as necessary. 642 * 643 * @param roleId the primary key of the role 644 * @param groupIds the primary keys of the groups 645 * @throws PortalException if the user did not have permission to update 646 * update the role 647 * @throws SystemException if a system exception occurred 648 */ 649 public void setRoleGroups(long roleId, long[] groupIds) 650 throws PortalException, SystemException { 651 652 RolePermissionUtil.check( 653 getPermissionChecker(), roleId, ActionKeys.ASSIGN_MEMBERS); 654 655 groupLocalService.setRoleGroups(roleId, groupIds); 656 } 657 658 /** 659 * Removes the groups from the role. 660 * 661 * @param roleId the primary key of the role 662 * @param groupIds the primary keys of the groups 663 * @throws PortalException if the user did not have permission to update the 664 * role 665 * @throws SystemException if a system exception occurred 666 */ 667 public void unsetRoleGroups(long roleId, long[] groupIds) 668 throws PortalException, SystemException { 669 670 RolePermissionUtil.check( 671 getPermissionChecker(), roleId, ActionKeys.ASSIGN_MEMBERS); 672 673 groupLocalService.unsetRoleGroups(roleId, groupIds); 674 } 675 676 /** 677 * Updates the group's friendly URL. 678 * 679 * @param groupId the primary key of the group 680 * @param friendlyURL the group's new friendlyURL (optionally 681 * <code>null</code>) 682 * @return the group 683 * @throws PortalException if the user did not have permission to update the 684 * group, if a group with the primary key could not be found, or if 685 * a valid friendly URL could not be created for the group 686 * @throws SystemException if a system exception occurred 687 */ 688 public Group updateFriendlyURL(long groupId, String friendlyURL) 689 throws PortalException, SystemException { 690 691 GroupPermissionUtil.check( 692 getPermissionChecker(), groupId, ActionKeys.UPDATE); 693 694 return groupLocalService.updateFriendlyURL(groupId, friendlyURL); 695 } 696 697 /** 698 * Updates the group's type settings. 699 * 700 * @param groupId the primary key of the group 701 * @param typeSettings the group's new type settings (optionally 702 * <code>null</code>) 703 * @return the group 704 * @throws PortalException if the user did not have permission to update the 705 * group or if a group with the primary key could not be found 706 * @throws SystemException if a system exception occurred 707 */ 708 public Group updateGroup(long groupId, String typeSettings) 709 throws PortalException, SystemException { 710 711 GroupPermissionUtil.check( 712 getPermissionChecker(), groupId, ActionKeys.UPDATE); 713 714 return groupLocalService.updateGroup(groupId, typeSettings); 715 } 716 717 /** 718 * Updates the group. 719 * 720 * @param groupId the primary key of the group 721 * @param name the group's new name 722 * @param description the group's new description (optionally 723 * <code>null</code>) 724 * @param type the group's new type. For more information see {@link 725 * com.liferay.portal.model.GroupConstants} 726 * @param friendlyURL the group's new friendlyURL (optionally 727 * <code>null</code>) 728 * @param active whether the group is active 729 * @param serviceContext the service context to be applied (optionally 730 * <code>null</code>). Can set the asset category IDs and asset tag 731 * names for the group. 732 * @return the group 733 * @throws PortalException if the user did not have permission to update the 734 * group, if a group with the primary key could not be found, if the 735 * friendly URL was invalid or could one not be created 736 * @throws SystemException if a system exception occurred 737 */ 738 public Group updateGroup( 739 long groupId, String name, String description, int type, 740 String friendlyURL, boolean active, ServiceContext serviceContext) 741 throws PortalException, SystemException { 742 743 GroupPermissionUtil.check( 744 getPermissionChecker(), groupId, ActionKeys.UPDATE); 745 746 return groupLocalService.updateGroup( 747 groupId, name, description, type, friendlyURL, active, 748 serviceContext); 749 } 750 751 protected List<Group> filterGroups(List<Group> groups) 752 throws PortalException, SystemException { 753 754 List<Group> filteredGroups = new ArrayList<Group>(); 755 756 for (Group group : groups) { 757 if (GroupPermissionUtil.contains( 758 getPermissionChecker(), group.getGroupId(), 759 ActionKeys.VIEW)) { 760 761 filteredGroups.add(group); 762 } 763 } 764 765 return filteredGroups; 766 } 767 768 }