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