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

Overlapping left/right categoryIds are added when creating asset categories

    Details

      Description

      Steps to Reproduce

      1. Start up Liferay connected to a MySQL database
      2. Sign in as admin
      3. Navigate to Control Panel > Configuration > Server Administration
      4. Go to the Script tab
      5. Run the following Groovy script:
        import com.liferay.asset.kernel.service.AssetVocabularyLocalServiceUtil;
        import com.liferay.asset.kernel.service.AssetCategoryLocalServiceUtil;
        import com.liferay.portal.kernel.model.GroupConstants
        import com.liferay.portal.kernel.service.GroupLocalServiceUtil
        import com.liferay.portal.kernel.service.ServiceContext;
        import com.liferay.portal.kernel.util.PortalUtil
        import com.liferay.portal.kernel.util.StringUtil
        
        import java.util.concurrent.Executors;
        
        userId = PortalUtil.getUserId(actionRequest);
        companyId = PortalUtil.getCompanyId(actionRequest);
        groupId = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST).getGroupId()
        
        serviceContext = new ServiceContext()
        
        vocabularyName = "Groovy_TestVocabulary"
        vocabulary = AssetVocabularyLocalServiceUtil.fetchGroupVocabulary(groupId, "Groovy_TestVocabulary")
        
        if (vocabulary == null) {
            vocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(userId, groupId, vocabularyName, serviceContext);
        }
        
        AssetCategoryLocalServiceUtil.addCategory(userId, groupId, "cat-" + StringUtil.randomString(5) + "-" + StringUtil.randomId(5), vocabulary.getVocabularyId(), serviceContext);
        
        overlappingCategory = AssetCategoryLocalServiceUtil.addCategory(userId, groupId, "cat-" + StringUtil.randomString(5) + "-" + StringUtil.randomId(5), vocabulary.getVocabularyId(), serviceContext);
        
        // Introduce overlapping left/right category ids to tree
        overlappingCategory.setLeftCategoryId(2);
        overlappingCategory.setRightCategoryId(3);
        
        AssetCategoryLocalServiceUtil.updateAssetCategory(overlappingCategory);
        
        // Add new category - Expected to detect broken tree and rebuild
        AssetCategoryLocalServiceUtil.addCategory(userId, groupId, "cat-" + StringUtil.randomString(5) + "-" + StringUtil.randomId(5), vocabulary.getVocabularyId(), serviceContext);
        
      6. Inspect the AssetCategory table in the database

      Actual Behavior
      Two rows show overlapping leftCategoryId and rightCategoryId.

      Expected Behavior
      Rows should have unique leftCategoryId and rightCategoryIds.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              chao.wang Chao Wang
              Reporter:
              eric.yan Eric Yan
              Participants of an Issue:
              Recent user:
              Enterprise Release HU
              Engineering Assignee:
              Eric Yan
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                4 weeks, 4 days ago

                  Packages

                  Version Package
                  7.1.X
                  7.2.10 DXP FP11
                  7.2.10.3 DXP SP4
                  7.2.X