PUBLIC - Liferay Portal Community Edition
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-5549

When importing LARs for new users, the layout tree structure is getting messed up

    Details

    • Liferay Contributor's Agreement:
      Accept
    • Similar Issues:
      Show 4 results 

      Description

      When importing simple page structures (with 3 levels), the layoutIds and parentLayoutIds get messed up. A simple solution for this problem is changing the code of the method

      public void importLayouts(
      long userId, long groupId, boolean privateLayout,
      Map<String, String[]> parameterMap, InputStream is)
      throws PortalException, SystemException {

      in the package com.liferay.portal.lar.LayoutImporter in such way:

      AT LINE 407
      else if (layoutsImportMode.equals(
      PortletDataHandlerKeys.
      LAYOUTS_IMPORT_MODE_MERGE_BY_LAYOUT_NAME)) {

      Locale locale = LocaleUtil.getDefault();

      String localizedName = LocalizationUtil.getLocalization(
      name, LocaleUtil.toLanguageId(locale));

      for (Layout curLayout : previousLayouts) {
      if (curLayout.getName(locale).equals(localizedName))

      { layout = curLayout; break; }

      }

      if (layout == null)

      { //------------------------------------------------------------------------------------------------------------------------------- //-------------COMMENT THE FOLLOWING LINE OUT TO GET THE LAYOUT IMPORT RIGHT ------ //------------------------------------------------------------------------------------------------------------------------------- // layoutId = LayoutLocalServiceUtil.getNextLayoutId( // groupId, privateLayout); //------------------------------------------------------------------------------------------------------------------------------- //-------------COMMENT THE FOLLOWING LINE OUT TO GET THE LAYOUT IMPORT RIGHT ------ //------------------------------------------------------------------------------------------------------------------------------- }

      }
      else

      { layout = LayoutUtil.fetchByG_P_L( groupId, privateLayout, layoutId); }

      With the above changes, everything works the way expected

        Activity

        Hide
        Igor Spasic added a comment - - edited

        Here is a test case, based on one posted on Olivers thread:

        1. create a usergroup called "Test-Group"

        2. create the following pages:
        Home, Test 1, Test 2, Test 3, Page 1, Page 2, Page 1.1 (as a child of Page 1), Page 1.2 (as a child of Page 1), Page 1.3 (as a child of Page 1)

        3. delete pages: Test 1 - Test 3

        4. The correct page structure in layout table (layoutid / parentlayoutid):
        Home (1 / 0)
        Page 1 (5 / 0)
        Page 2 (6 / 0)
        Page 1.1 (7 / 5)
        Page 1.2 (8 / 5)
        Page 1.3 (9 / 5)

        5. export all pages, and then delete them

        6. import exported LAR

        7. the new values are:
        Home (10 / 0)
        Page 1 (11 / 0)
        Page 2 (12 / 0)
        Page 1.1 (13 / 11)
        Page 1.2 (14 / 11)
        Page 1.3 (15 / 11)

        Note that ID values may change, however, the functionality is ok.

        Show
        Igor Spasic added a comment - - edited Here is a test case, based on one posted on Olivers thread: 1. create a usergroup called "Test-Group" 2. create the following pages: Home, Test 1, Test 2, Test 3, Page 1, Page 2, Page 1.1 (as a child of Page 1), Page 1.2 (as a child of Page 1), Page 1.3 (as a child of Page 1) 3. delete pages: Test 1 - Test 3 4. The correct page structure in layout table (layoutid / parentlayoutid): Home (1 / 0) Page 1 (5 / 0) Page 2 (6 / 0) Page 1.1 (7 / 5) Page 1.2 (8 / 5) Page 1.3 (9 / 5) 5. export all pages, and then delete them 6. import exported LAR 7. the new values are: Home (10 / 0) Page 1 (11 / 0) Page 2 (12 / 0) Page 1.1 (13 / 11) Page 1.2 (14 / 11) Page 1.3 (15 / 11) Note that ID values may change, however, the functionality is ok.
        Hide
        Igor Spasic added a comment -

        Tested on 5.2.x trunk and it works.

        Show
        Igor Spasic added a comment - Tested on 5.2.x trunk and it works.
        Hide
        Oliver Bayer added a comment -

        Hi Igor,

        thanks for your work in reproducing the error. But I think there is a modification of your testcase in contrary to mine.

        Can you please try to assign a new user to this usergroup (without deleting the page structure of #4)? After the layout import the user shouldn't see the subpages (1.1-1.3) as I described in my forum post at #6. That happens because the layout importer starts from layoutid 1 (if no layout exists - which is the case for a new user who was added to the usergroup) and don't change the parentlayoutid the same way (it takes the parentlayoutid from the lar file but creating a new layoutid).

        If this still works on 5.2.x trunk please give it a try on 5.2.3 which is the latest stable release. As you see from my post the bug is reproducable by others in v5.2.3. BTW it's good to hear that it's fixed in trunk and v6 .

        Thanks.

        Show
        Oliver Bayer added a comment - Hi Igor, thanks for your work in reproducing the error. But I think there is a modification of your testcase in contrary to mine. Can you please try to assign a new user to this usergroup (without deleting the page structure of #4)? After the layout import the user shouldn't see the subpages (1.1-1.3) as I described in my forum post at #6. That happens because the layout importer starts from layoutid 1 (if no layout exists - which is the case for a new user who was added to the usergroup) and don't change the parentlayoutid the same way (it takes the parentlayoutid from the lar file but creating a new layoutid). If this still works on 5.2.x trunk please give it a try on 5.2.3 which is the latest stable release. As you see from my post the bug is reproducable by others in v5.2.3. BTW it's good to hear that it's fixed in trunk and v6 . Thanks.
        Hide
        Igor Spasic added a comment -

        Hey Oliver, thank you for your patience

        Here is the updated test case:

        1. create a usergroup called "Test-Group"

        2. for this group create the following pages in given order:
        Home, Test 1, Test 2, Test 3, Page 1, Page 2, Page 1.1 (as a child of Page 1), Page 1.2 (as a child of Page 1), Page 1.3 (as a child of Page 1)

        3. delete pages: Test 1 - Test 3

        4. The correct page structure in layout table (layoutId / parentLayoutId):
        Home (1 / 0)
        Page 1 (5 / 0)
        Page 2 (6 / 0)
        Page 1.1 (7 / 5)
        Page 1.2 (8 / 5)
        Page 1.3 (9 / 5)

        5. create a testuser and assign him/her to the "Test-Group".
        If you go to users pages, you should see the exact structure.
        In database, user pages should have the following values:
        Home (1 / 0)
        Page 1 (2 / 0)
        Page 2 (3 / 0)
        Page 1.1 (4 / 2)
        Page 1.2 (5 / 2)
        Page 1.3 (6 / 2)

            • Portal 5.2.3 already fails here ***
              You will not see the children pages (Page 1.1 - Page 1.3), just the top pages.
        Show
        Igor Spasic added a comment - Hey Oliver, thank you for your patience Here is the updated test case: 1. create a usergroup called "Test-Group" 2. for this group create the following pages in given order: Home, Test 1, Test 2, Test 3, Page 1, Page 2, Page 1.1 (as a child of Page 1), Page 1.2 (as a child of Page 1), Page 1.3 (as a child of Page 1) 3. delete pages: Test 1 - Test 3 4. The correct page structure in layout table (layoutId / parentLayoutId): Home (1 / 0) Page 1 (5 / 0) Page 2 (6 / 0) Page 1.1 (7 / 5) Page 1.2 (8 / 5) Page 1.3 (9 / 5) 5. create a testuser and assign him/her to the "Test-Group". If you go to users pages, you should see the exact structure. In database, user pages should have the following values: Home (1 / 0) Page 1 (2 / 0) Page 2 (3 / 0) Page 1.1 (4 / 2) Page 1.2 (5 / 2) Page 1.3 (6 / 2) Portal 5.2.3 already fails here *** You will not see the children pages (Page 1.1 - Page 1.3), just the top pages.
        Hide
        Igor Spasic added a comment -

        this bug exist in v5.2.3 release, but not on latest 5.2.x trunk - it is already solved.

        Show
        Igor Spasic added a comment - this bug exist in v5.2.3 release, but not on latest 5.2.x trunk - it is already solved.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              4 years, 50 weeks, 3 days ago

              Development

                Structure Helper Panel