Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-68695

"RequiredUserGroupException" error is thrown when trying to delete a User Group or Organization with API



      Reproduction Steps:

      1. Optional in 6.2.x: configure Solr 4 for Liferay 6.2. I couldn't reproduce the issue using Lucene.
      2. Start a Liferay tomcat bundle
      3. Log on as administrator user ("test")
      4. Go to Control Panel -> Server Administration -> Script
        and run the attached groovy script: remove_usergroup... or remove_organization...

      The script performs these actions:

      • a new userGroup/organization is created
      • a new user is created and added to the usergroup
      • the user is removed from the usergroup/organization
      • the usergroup/organization is deleted

      Expected results:
      The last action (usergroup deletion) should complete without error messages, because the group members were already removed

      Actual Results:
      A "RequiredUserGroupException" message is thrown when trying to delete the usergroup.

      Detailed information on root cause:
      " The same issue occurs when trying to remove Organizations.
      When trying to remove an organization and/or a usergroup after removing its associated users, we get the following exceptions :

      • Usergroup : com.liferay.portal.RequiredUserGroupException
      • Organization: com.liferay.portal.RequiredOrganizationException

      We are using the following API to remove users :

      • usergroups : UserLocalServiceUtil.unsetUserGroupUsers
      • organizations : UserLocalServiceUtil.unsetOrganizationUsers

      We found out that those two methods are reindexing search index User document after the assocation between user and usergroup/organization has been removed. However, when trying to remove the organization/usergroup using the methods :

      • usergroup : UserGroupLocalServiceUtil.deleteUserGroup(usergroup)
      • organization: OrganizationLocalServiceUtil.deleteOrganization(organization)

      The first action in those two methods is to retrieve the users count in usergroup/organization:

      • Usergroup : userLocalService.getUserGroupUsersCount
      • Organization: userLocalService.getOrganizationUsersCount

      Those two methods are calling the Search Index to retrieve the count. As the search index may not be up to date at the time being due to an asynchronous process to reindex user, the RequiredOrganizationException/RequiredUserGroupException exception is raised, even though the users relations were previously removed. "

      Reproduced on 6.2.x (865b426c13a129dec3d3ca3ac6a1b75d378e32d2)
      Reproduced on Master (ee853d5384071a1af8b730a4d31076688175b0f8)


        1. remove_organization_with_unset_62x.groovy
          2 kB
          Norbert Kocsis
        2. remove_organization_with_unset_MASTER_update.groovy
          3 kB
          Shitian "Shelton" Zhang
        3. remove_organization_with_unset_MASTER.groovy
          2 kB
          Norbert Kocsis
        4. remove_usergroup_with_unset_62x.groovy
          2 kB
          Norbert Kocsis
        5. remove_usergroup_with_unset_MASTER.groovy
          2 kB
          Norbert Kocsis

        Issue Links



              shitian.zhang Shitian "Shelton" Zhang (Inactive)
              norbert.kocsis Norbert Kocsis (Inactive)
              Kiyoshi Lee Kiyoshi Lee
              0 Vote for this issue
              3 Start watching this issue


                5 years, 38 weeks, 1 day ago


                  Version Package
                  6.2.X EE
                  7.0.0 DXP FP8
                  7.0.0 DXP SP2
                  7.0.3 CE GA4