Details

      Description

      LayoutsTreeImpl retrieves in memory al records, and afterwards applies pagination.

       

      Steps to Reproduce:

      1. Create a site named Site1
      2. Add 21 public pages for Site1.
      3. Execute the the following Groovy script (replace the value of groupId with Site1 identifier):
      import com.liferay.portlet.layoutsadmin.util.LayoutsTreeUtil;
      import com.liferay.portal.kernel.util.PortalUtil;
      import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
      import com.liferay.portal.kernel.dao.orm.FinderPath;
      import com.liferay.portal.service.persistence.impl.LayoutPersistenceImpl;
      import com.liferay.portal.kernel.service.LayoutLocalServiceUtil;
      import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
      import com.liferay.portal.kernel.service.LayoutLocalService;
      import com.liferay.portal.kernel.dao.orm.FinderPath;
      import com.liferay.portal.model.impl.LayoutModelImpl;
      import com.liferay.portal.service.persistence.impl.LayoutPersistenceImpl;
      import com.liferay.portal.model.impl.LayoutImpl;
      import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
      import com.liferay.portal.kernel.cache.PortalCache;
      import com.liferay.portal.kernel.dao.orm.FinderCache;
      import com.liferay.portal.kernel.util.OrderByComparator;
      
      
      long groupId = 36939L;
      
      String nonPaginatedCacheKey = getNonPaginatedCacheKey(groupId);
      String paginatedCacheKey = getPaginatedCacheKey(groupId);
      
      PortalCache portalCacheNonPaginated = MultiVMPoolUtil.getPortalCache(FinderCache.class.getName() + "." + LayoutPersistenceImpl.FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
      PortalCache portalCachePaginated = MultiVMPoolUtil.getPortalCache(FinderCache.class.getName() + "." + LayoutPersistenceImpl.FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
      
      portalCacheNonPaginated.remove(nonPaginatedCacheKey);
      portalCachePaginated.remove(paginatedCacheKey);
      
      LayoutsTreeUtil.getLayoutsJSON(PortalUtil.getHttpServletRequest(actionRequest), groupId, "Tree");
      
      out.println("Uses no pagination: " + !isNullOrEmpty(portalCacheNonPaginated.get(nonPaginatedCacheKey)));
      
      out.println("Uses pagination: " + !isNullOrEmpty(portalCachePaginated.get(paginatedCacheKey)));
      
      
      String getNonPaginatedCacheKey(long groupId) {
          boolean pagination = false;
          FinderPath finderPath = new FinderPath(LayoutModelImpl.ENTITY_CACHE_ENABLED, LayoutModelImpl.FINDER_CACHE_ENABLED, LayoutImpl.class,
                                      LayoutPersistenceImpl.FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_P_Head",
                                      [Long.class.getName(), Boolean.class.getName(), Long.class.getName(), Boolean.class.getName()] as String[],
                                      LayoutModelImpl.GROUPID_COLUMN_BITMASK | LayoutModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
                                      LayoutModelImpl.PARENTLAYOUTID_COLUMN_BITMASK | LayoutModelImpl.HEAD_COLUMN_BITMASK |
                                      LayoutModelImpl.PRIORITY_COLUMN_BITMASK);
      
          Object[] finderArgs = [groupId, false, 0L, true];
          
          String encodedArguments = finderPath.encodeArguments(finderArgs);
      
          return finderPath.encodeCacheKey(encodedArguments);
      }
      
      String getPaginatedCacheKey(long groupId) {
          boolean pagination = true;
          FinderPath finderPath = new FinderPath(LayoutModelImpl.ENTITY_CACHE_ENABLED, LayoutModelImpl.FINDER_CACHE_ENABLED, LayoutImpl.class,
                           LayoutPersistenceImpl.FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_P_Head",
                           [Long.class.getName(), Boolean.class.getName(), Long.class.getName(), Boolean.class.getName(),
                           Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName()] as String[]);
      
          Object[] finderArgs = finderArgs = [groupId, false, 0L, true, 0, 20, null];
      
          String encodedArguments = finderPath.encodeArguments(finderArgs);
      
          return finderPath.encodeCacheKey(encodedArguments);
      }
      
      boolean isNullOrEmpty(Collection collection) {
          return collection == null || collection.isEmpty();
      }
      

      Expected Results:

      The script should indicate the following:

      Uses no pagination: false
      Uses pagination: true
      

      Actual Results:

      The script indicates the following:

      Used no pagination: true
      Used pagination: false
      

      What the script does is the following:

      1. Calls LayoutsTreeImpl
      2. Checks if the cache contains a record based on pagination
      3. Checks if the cache contains a record not based on pagination.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                5 weeks, 2 days ago