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

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                1 day ago

                Packages

                Version Package
                7.2.10 DXP FP7
                Master