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

My Account page can become too large for users with many roles

    Details

      Description

      My Account page can become much too large.

      Steps

      1. Control Panel > Server Admin > Scripts
      2. Run this script:
        import com.liferay.portal.kernel.util.StringPool;
        import com.liferay.portal.kernel.util.UniqueList;
        import com.liferay.portal.model.ListTypeConstants;
        import com.liferay.portal.model.Organization;
        import com.liferay.portal.model.Role;
        import com.liferay.portal.model.RoleConstants;
        import com.liferay.portal.model.User;
        import com.liferay.portal.model.UserGroupRole;
        import com.liferay.portal.service.OrganizationLocalServiceUtil;
        import com.liferay.portal.service.RoleLocalServiceUtil;
        import com.liferay.portal.service.UserGroupRoleLocalServiceUtil;
        import com.liferay.portal.service.UserLocalServiceUtil;
        import com.liferay.portal.service.ServiceContext;
        import com.liferay.portal.service.ServiceContextFactory;
        import com.liferay.portal.service.UserServiceUtil;
        import com.liferay.portal.service.persistence.UserGroupRolePK;
        import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
        
        import javax.portlet.ActionRequest;
        import java.util.ArrayList;
        import java.util.List;
        
        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
        
        long userId = serviceContext.getUserId();
        
        User user = UserLocalServiceUtil.getUser(userId);
        
        Organization organization =
        	OrganizationLocalServiceUtil.addOrganization(
        		userId, 0, "Test Organization", "regular-organization", 0, 0,
        		ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, StringPool.BLANK,
        		false, serviceContext);
        
        System.out.println("Organization: " + organization.getName() + " created.");
        
        long[] roleIds = new long[1000];
        
        for (int i = 0; i < roleIds.length; i++) {
        	Role role = RoleLocalServiceUtil.addRole(
        		userId, null, 0, "Test organizatonal Role #" + i, null, null,
        		RoleConstants.TYPE_ORGANIZATION, StringPool.BLANK,
        		serviceContext);
        
        	roleIds[i] = role.getRoleId();
        
        	System.out.println("Role: " + role.getName() + " created.");
        }
        
        long organizationId = organization.getOrganizationId();
        
        long[] organizationIds = new long[1];
        
        organizationIds[0] = organizationId;
        
        List<UserGroupRole> userGroupRoles =
        	new UniqueList<UserGroupRole>(
        		UserGroupRoleLocalServiceUtil.getUserGroupRoles(
        			user.getUserId()));
        
        UserServiceUtil.updateUser(
        	user.getUserId(), user.getPassword(), StringPool.BLANK,
        	StringPool.BLANK, false, StringPool.BLANK, StringPool.BLANK,
        	user.getScreenName(), user.getEmailAddress(),
        	user.getFacebookId(), user.getOpenId(), false, null,
        	user.getLanguageId(), user.getTimeZoneId(), user.getGreeting(),
        	user.getComments(), user.getFirstName(), user.getMiddleName(),
        	user.getLastName(), 0, 0, user.getMale(),
        	user.getBirthday().getMonth(), user.getBirthday().getDay(),
        	user.getBirthday().getYear(), StringPool.BLANK, StringPool.BLANK,
        	StringPool.BLANK, StringPool.BLANK, StringPool.BLANK,
        	StringPool.BLANK, StringPool.BLANK, StringPool.BLANK,
        	StringPool.BLANK, StringPool.BLANK, StringPool.BLANK,
        	user.getGroupIds(), organizationIds, user.getRoleIds(),
        	userGroupRoles, user.getUserGroupIds(),
        	user.getAddresses(), user.getEmailAddresses(), user.getPhones(),
        	user.getWebsites(), new ArrayList<AnnouncementsDelivery>(),
        	serviceContext);
        
        for (long roleId : roleIds) {
        	UserGroupRolePK userGroupRolePK = new UserGroupRolePK(
        		userId, organization.getGroupId(), roleId);
        
        	UserGroupRole userGroupRole =
        		UserGroupRoleLocalServiceUtil.createUserGroupRole(
        			userGroupRolePK);
        
        	userGroupRoles.add(userGroupRole);
        }
        
        UserServiceUtil.updateUser(
        	user.getUserId(), user.getPassword(), StringPool.BLANK,
        	StringPool.BLANK, false, StringPool.BLANK, StringPool.BLANK,
        	user.getScreenName(), user.getEmailAddress(),
        	user.getFacebookId(), user.getOpenId(), false, null,
        	user.getLanguageId(), user.getTimeZoneId(), user.getGreeting(),
        	user.getComments(), user.getFirstName(), user.getMiddleName(),
        	user.getLastName(), 0, 0, user.getMale(),
        	user.getBirthday().getMonth(), user.getBirthday().getDay(),
        	user.getBirthday().getYear(), StringPool.BLANK, StringPool.BLANK,
        	StringPool.BLANK, StringPool.BLANK, StringPool.BLANK,
        	StringPool.BLANK, StringPool.BLANK, StringPool.BLANK,
        	StringPool.BLANK, StringPool.BLANK, StringPool.BLANK,
        	user.getGroupIds(), organizationIds, roleIds,
        	userGroupRoles, user.getUserGroupIds(),
        	user.getAddresses(), user.getEmailAddresses(), user.getPhones(),
        	user.getWebsites(), new ArrayList<AnnouncementsDelivery>(),
        	serviceContext);
        
        System.out.println("User: " + user.getScreenName() + " updated.");
        
      3. Go to the My account page
      4. Save the page as a file noting the size
      5. Create another user and edit them
      6. Save the edit user page noting the size

      Result
      Expected:
      My Account page should scale and not increase in size with the number of roles.
      Actual:
      My Account page increases linearly with the number of roles.

      Note: this will be difficult to test until LPS-46878 is resolved.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 years, 12 weeks, 6 days ago

                  Packages

                  Version Package
                  6.2.3 CE GA4
                  6.2.X EE
                  7.0.0 M3