juliocamarero/liferay-portal — pull request #3110 by IstvanD (2014-11-10 16:10:39+00:00)
Title: [TECH-SUPPORT] LPS-48901 Global structure default values are not restored

Hey Julio,

I reviewed my modification is https://github.com/juliocamarero/liferay-portal/pull/3039, and I found that when s structure not exists, calling DDMStructureServiceUtil.getStructure() with themeDisplay.getCompanyGroupId() (to find the structure in the Global scope) is basically pointless, since the searching for the parent structures will fail when DDMStructurePermission.check() is called.

This calls DDMStructurePermission.contains(), where the line

DDMStructure structure = DDMStructureLocalServiceUtil.getStructure(
groupId, classNameId, structureKey);

will not return any anything, since the structure with that groupId, classNameId and structureKey doesn't exists. This is why DDMStructureServiceUtil.getStructure() was called with parameter true, to find the parent structures in the first place.

However if we call DDMStructureLocalServiceUtil.getStructure() with includeAncestorStructures set to true
in the contains() method, the global and even the parent structures will be found.
This is what you see in this pull request.

I thought that what if we extend the signature of the check() and contains() method with the boolean parameter includeAncestorStructures, just like in getStructure(), so that I we wanted to search in the hierarchy upwards, we would do the same with permission checking.

I'm looking forward to your answer.

Best regards,
István