Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Oliver Bayer
LayoutImporter Bugs
December 7, 2009 2:06 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi @all,

first of all I noticed the following in the LayoutImporter class (Liferay 5.2.3). Why is the same PortletDataHandlerKeys used for getting the permissions on the one side and on the other side to read the user permissions? In PortletDataHandlerKeys there is an own "USER_PERMISSIONS" string defined. Is this usage correct or should it be fixed?

1boolean importPermissions = MapUtil.getBoolean(
2    parameterMap, PortletDataHandlerKeys.PERMISSIONS);
3boolean importUserPermissions = MapUtil.getBoolean(
4    parameterMap, PortletDataHandlerKeys.PERMISSIONS);

The bug I've found occured during the import of lar files. Under some situations the imported page structure messed up e.g.:
-page 1 (layoutId=1, parentLayoutId=0)
-page 2 (layoutId=20, parentLayoutId=0)
-page 2.1 (layoutId=21, parentLayoutId=20)
-page 3 (layoutId=22, parentLayoutId=0)

After the import the new structure looks like the following list:
-page 1 (layoutId=1, parentLayoutId=0) OK
-page 2 (layoutId=2, parentLayoutId=0) NOT OK
-page 2.1 (layoutId=21, parentLayoutId=20) NOT OK
-page 3 (layoutId=3, parentLayoutId=0)

During the import all top level sites gets imported. So if a site has a layoutId which doesn't fit the new layoutId (given by the importer) all child pages of this page doesn't show up in the navigation or are randomly placed in the navigation site tree.

The code which sets the wrong layoutId:
1if (layout == null) {
2    layoutId = LayoutLocalServiceUtil.getNextLayoutId(groupId, privateLayout);
3}

The solution:
If a page gets a new layoutId the child pages should refer this new layoutId as parentLayoutId. In the example the page 2.1 should get the following parentLayoutId:
-page 2.1 (layoutId=21, parentLayoutId=2) OK

A ticket for this issue is already created: LayoutImporter breaks site structure.
Any feedback is appreciated.

Oli
Oliver Bayer
RE: LayoutImporter Bugs
December 17, 2009 1:21 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Another bug I've found occured during import of the usergroup-layouts.

If a user is editing his/her page while the LayoutImporter starts the following two errors can occur (but not always):

- the user sees a "blank/ white" page during page refresh

- the user adds a portlet e.g. web content display, selects an article and clicks on edit but after the LayoutImporter finished the portlet isn't displayed any more (in the table "portletpreferences" the preferences of this portlet are stored but in the "layout" table the web content display portlet id doesn't show up in the field "typesettings" in any column)

How to get rid of this behaviour??
Ray Augé
RE: LayoutImporter Bugs
December 17, 2009 7:34 AM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1238

Join Date: February 7, 2005

Recent Posts

If possible, can you induce this behavior in a LAR and attach it so that we can test this scenario?

That would be very helpful.

(don't worry about the portal version issue, we'll match it up, I have some alpha code to handle imports between versions)
Oliver Bayer
RE: LayoutImporter Bugs
December 18, 2009 2:51 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi Ray,

thanks for answering,
I've created the attached lar file with a fresh liferay installation without any modifications.

The test scenario:

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 Test 1-Test 3 pages

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"

6. after the layout import the user has the following wrong page structure in layout table (layoutid/ parentlayoutid):
Home (1/ 0),
Page 1 (2/ 0) gets new layoutid by LayoutImporter,
Page 2 (3/ 0),
Page 1.1 (4/ 5 it should be 4/ 2),
Page 1.2 (5/ 5 it should be 5/ 2),
Page 1.3 (6/ 5 it should be 6/ 2)


So the pages 1.1 - 1.3 don't show up in the navigation anymore because they're getting the wrong parentlayoutid during import. The parentlayoutid is the one from the lar file while the layoutid is newly created.

It's quite a long explanaition but I hope this helps you to reproduce the error.

Greets Oli
Attachments: Test-Group-200912181110.lar (676.4k)
Oliver Bayer
RE: LayoutImporter Bugs
December 23, 2009 4:37 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hello Ray,

could you use the lar file to reproduce the layout import error?
BTW merry xmas.

Oli
Oliver Bayer
RE: LayoutImporter Bugs
January 11, 2010 12:54 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi Ray,

any info about the layout importer bug?? Have you been able to reproduce the error with the given lar file?

Oli
Oliver Bayer
RE: LayoutImporter Bugs
February 11, 2010 4:02 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

bump
Oliver Bayer
RE: LayoutImporter Bugs
March 10, 2010 1:02 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi Ray,

any updates on the LayoutImporter Bugs?
zaheer mohammed saddapalli
RE: LayoutImporter Bugs
March 24, 2010 10:58 PM
Answer

zaheer mohammed saddapalli

Rank: Regular Member

Posts: 164

Join Date: January 15, 2008

Recent Posts

Hi Oli,

I observed some has resolved this issue. Please have a look.
Importing LARS
Oliver Bayer
RE: LayoutImporter Bugs
March 25, 2010 2:49 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi Zaheer,

thanks for the info.
The bugfix you've mentioned was created by one of my colleagues emoticon.
We want Liferay to fix this critical bug for the new Liferay 6 release. Because of this I've created a lar file for the developers to be able to reproduce the error but as you can see I don't get any info/feedback how they make progress.

Greets Oli
zaheer mohammed saddapalli
RE: LayoutImporter Bugs
March 26, 2010 2:01 AM
Answer

zaheer mohammed saddapalli

Rank: Regular Member

Posts: 164

Join Date: January 15, 2008

Recent Posts

Hi Oli,

I don't know that your colleagues has resolved it.

You are right they should consider it. It's already too late.

Me too expecting this fix atleast in from Liferay 6.
Felix Meinhold
RE: LayoutImporter Bugs
July 13, 2010 11:38 AM
Answer

Felix Meinhold

Rank: New Member

Posts: 8

Join Date: December 3, 2007

Recent Posts

we were experiencing the same behavior in liferay ee 5.2 SP4. thanks to oli and thomas and the new ext plugin we were able to fix this bug.
Oliver Bayer
RE: LayoutImporter Bugs
July 14, 2010 12:53 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi Felix,

thanks for the positive feedback. We stuck a while with this annoying error and we're glad to see that the bugfix works for you too.

Oli
Felix Meinhold
RE: LayoutImporter Bugs
July 21, 2010 6:41 AM
Answer

Felix Meinhold

Rank: New Member

Posts: 8

Join Date: December 3, 2007

Recent Posts

Hi Oli,

we still have trouble updating Layouts from stage to Live. Adding new ones works fine.

So I decided to add the staging layout-id to the typesettings of the live layout and search for this first- which seems to work for now.

-felix
Oliver Bayer
RE: LayoutImporter Bugs
July 22, 2010 1:34 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi Felix,

thanks for the info.

We're not using staging atm but in a quick test we don't ran into problems. What do you mean with "update problems"? So can you please share your modifications and upload your new LayoutImporter class?

Oli
Felix Meinhold
RE: LayoutImporter Bugs
July 22, 2010 2:09 AM
Answer

Felix Meinhold

Rank: New Member

Posts: 8

Join Date: December 3, 2007

Recent Posts

Hi Oli,

i haven't reproduced the error in a clean install yet. And my "fix"
almost certainly breaks the regular LAR Import function of the
layoutimporter, that's why i didn't post it.

some info about our environment:

we created staging from live with about 3000 Layouts.
the layoutId counter in the "COUNTER" table is different for staging /
public- this happens because e.g. people create and delete layouts in staging without publishing them.

so if we:

1)
create a new site (with or without descendants)
publish it.
everything's fine, since there is a new layoutid for every page.

2)
update a site (with dependencies)
- it tries to find the layout by the layoutid found in the exported
xml, the staging layoutid.
- it tries to create a new layout with same friendlyURL ... unique
constraint violation.

I needed a quick fix for that, so i did the following:

First i added a method for finding the Live Layout by friendlyURL- but
then you can't change the FriendlyURL for a Live page.

So i added the staging layout id to the live layouts (_stage-layout-id):
 1
 2      List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(stageGroupId, false);
 3      for (Layout layout : layouts) {
 4         try {
 5            Layout targetLayout = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, false, layout.getFriendlyURL());
 6            targetLayout.getTypeSettingsProperties().setProperty("_stage-layout-id", Long.toString(layout.getLayoutId()));
 7            LayoutLocalServiceUtil.updateLayout(targetLayout);
 8         } catch (NoSuchLayoutException ignore) {
 9         }
10      }


and in LayoutImporter, added a method for finding the Layout by layout-id. this is called for every reference of a layoutid in layoutimporter (including the very broken deletePage... and parentLayoutId).

 1
 2private Layout findByStageLayoutId(long stageLayoutId) throws SystemException {
 3      DynamicQuery dq = DynamicQueryFactoryUtil.forClass(Layout.class)
 4      .add(PropertyFactoryUtil.forName("typeSettings").like(String.format("%%_stage-layout-id=%d\n%%", stageLayoutId))); // I am assuming here there's always a "\n" at the end of TYPESETTINGS.
 5   
 6      List<Object> result = LayoutLocalServiceUtil.dynamicQuery(dq);
 7      // Very Quick and VERY dirty...
 8      if (result.size() == 1) {
 9         Layout layout = (Layout) result.get(0);
10         return layout;
11      }
12      return null;
13}


That works for now. *cough*
Oliver Bayer
RE: LayoutImporter Bugs
July 22, 2010 5:58 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 862

Join Date: February 18, 2009

Recent Posts

Hi,


your description of the bug seems to be similar to the "easier" one we fixed for a while.

As you can see I don't get any answers from a liferay developer since last christmas. So it seems that we have to fix it on our own and I hope you can find a bugfix which doesn't break the normal LayoutImporter.

If you need any info about our bugfix feel free to ask.

Greets Oli
Felix Meinhold
RE: LayoutImporter Bugs
July 22, 2010 6:25 AM
Answer

Felix Meinhold

Rank: New Member

Posts: 8

Join Date: December 3, 2007

Recent Posts

Hi,

since i won't have to use the layoutimporter in the way it was intended anytime soon, i might not come up with a real fix (and can still just turn my LayoutImporter class off in -ext.xml). but i'll let you know if there's anything new. BEFORE christmas, i guess.