hhuijser/liferay-portal — pull request #2051 by yuhai (2014-07-29 05:02:53+00:00)
Title: LPS-44761  Site editors can't filter web content by structure

The pull request extends from https://github.com/hhuijser/liferay-portal/pull/1980.

I follow Julio's logic to complete the fix. I want to explain the fix by the below points.

1. I remove groupId =0 situation in ArticleDisplayTerms.java. Because I think it isn't needed if use this logic. And it will throw exception "Group siteGroup = doGetCurrentSiteGroup(groupId);" in PortalImpl.getSharedContentSiteGroupIds().

2. For using getSharedContentSiteGroupIds(), if using the same admin to create all sites, it almost can get all groupIds from the below code fragment:

in PortalImpl.getSharedContentSiteGroupIds()
// Administered sites
if (true) { // sites.content.sharing.through.administrators.enabled=true
......
groups.addAll(
GroupLocalServiceUtil.search(companyId, null, null, groupParams, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null));
}

related sql : SELECT * from Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE ...

So the method only applies in Global site because only global structure can be applied in other sites. You can see the judge in my fix 152 lines from view_entries.jsp

3. In other sites, except Global site, we also need to further filter groupId. Because the solution uses the similiar sql is as the followings:

Select * from JournalArticle where (JournalArticle.groupId = otherSites or JournalArticle.groupId = currentSite) and structureId = globalSite's structureId.

In the precondition (in other sites), when we click the detailed structure, we can firstly get the structure and it belong to which sites. Then we can use structure's own site to append the groupId as the followings:.

in view_entries.jsp.
a. If the structure belongs to GlobalSite, it should only return the current site's groupId. 161 lines express this.

b.If the structure doesn't belong to GlobalSite. It might be from parentSite or currentSite.

b.1 if structure belongs to parentSite, it should add the current site's groupId. It means we should only display the current site's article by using parentSite's structure created in child site.
b.2 If the structure belongs to currentSite, it should add the currentSite and DescendantsSite's groupId. The 169 line code express this.

In this pull request, due to I didn't work on time, there are some conflicts between master and Julio's pull request. I have merged the conflict. But I don't make sure whether I did correctly.

Would you please firstly check whether the logic is correct?

Thanks,
Hai