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

Web content API is not working as expected inside folder

    Details

      Description

      Description:
      The JournalArticleServiceUtil.getGroupArticlesCount(groupId,userId,rootFolderId,status,includeOwner) API call returns wrong result.

      Reproduction steps:

      1. Set up and start a bundle
      2. Log in with default admin user "test"
      3. Create a new site (note the groupId of the new site, it will be required for the testing Groovy script)
      4. Create a web content folder called "testfolder"
      5. Create 4 Basic Web Contents inside "testfolder"
      6. Go to Control Panel --> Configuration --> Server Administration --> select script and add the following Groovy script in order to list the web contents in the folder:

      import com.liferay.journal.service.JournalArticleServiceUtil;
      import com.liferay.journal.service.JournalFolderLocalServiceUtil;
      import com.liferay.portal.kernel.service.GroupLocalServiceUtil;
      import com.liferay.portal.kernel.service.UserLocalServiceUtil;
      
      long groupId = <insert groupId here>;
      
      long companyId = GroupLocalServiceUtil.getGroup(groupId).getCompanyId();
      long folderId = JournalFolderLocalServiceUtil.fetchFolder(groupId,"testfolder").getFolderId();
      long userId = UserLocalServiceUtil.getUserIdByScreenName(companyId, "test");
      
      list = JournalArticleServiceUtil.getGroupArticles(groupId,userId,folderId,0,false,-1,-1,null); 
      out.println("getGroupArticles() returned "+list.size()+" items"); 
      
      long count = JournalArticleServiceUtil.getGroupArticlesCount(groupId,userId,folderId,0,false); 
      out.println("getGroupArticlesCount() returned "+count);
      

      Actual result:

      getGroupArticles() returned 4 items
      getGroupArticlesCount() returned 0
      

      Expected result:

      getGroupArticles() returned 4 items
      getGroupArticlesCount() returned 4
      

      Notes:
      The reason is that in the generated count query, folderId and userId are swapped in JournalArticleFinderImpl.doCountByG_F_C(..):

      SELECT COUNT(DISTINCT JournalArticle.articleId) AS COUNT_VALUE
      FROM JournalArticle
      LEFT JOIN JournalArticle tempJournalArticle
      	ON (JournalArticle.status = 0)
      	AND (tempJournalArticle.status = 0)
      	AND (JournalArticle.groupId = tempJournalArticle.groupId)
      	AND (JournalArticle.articleId = tempJournalArticle.articleId)
      	AND (JournalArticle.version < tempJournalArticle.version)
      WHERE (JournalArticle.groupId = 39101)
      AND (JournalArticle.classNameId = 0)
      AND ((JournalArticle.folderId = 39107 )) -- wrong place
      AND (JournalArticle.userId = 20125 -- wrong place
      AND  JournalArticle.status = 0)
      AND (tempJournalArticle.id_ IS NULL)   
      

        Attachments

          Activity

            People

            Assignee:
            chao.wang Chao Wang
            Reporter:
            vendel.toreki Vendel Töreki
            Participants of an Issue:
            Recent user:
            Jason Pince
            Engineering Assignee:
            Vendel Töreki
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 35 weeks, 3 days ago

                Packages

                Version Package
                7.1.X
                7.2.10 DXP FP5
                7.2.10.2 DXP SP2
                7.2.X
                7.3.0 CE GA1
                7.3.10 DXP GA1
                Master