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

addRole with role and multiple parameters behaves differently

Details

    Description

      UserLocalService/UserLocalServiceUtil provides two methods to add a role:

      Role addRole(long userId, String className, long classPK, String name, Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, int type, String subtype, ServiceContext serviceContext)

      and

      addRole(Role role)

      But these two methods behave differently.

      addRole(role) just adds the role to the database, but the method with multiple parameters also calls resourceLocalService.addResources(...) and possible reindexes.

       

      See:

      https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/service/impl/RoleLocalServiceImpl.java#L172

      Basically, it is an error to create a role using createRole + addRole(role), because then the resource is missing and you won't see the role in the control panel.

      Attachments

        Activity

          People

            sharry.shi Sharry Shi
            crabel Christoph Rabel
            Brian Wulbern Brian Wulbern
            Russell Bohl Russell Bohl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              2 years, 43 weeks, 4 days ago

              Packages

                Version Package
                7.0.0 DXP FP94
                7.0.10.15 DXP SP15
                7.1.10 DXP FP19
                7.1.10.5 SP5
                7.2.10 DXP FP7
                7.3.X
                Master