juliocamarero/liferay-portal — pull request #2975 by matethurzo (2014-07-11 08:00:56+00:00)
Title: LPS-48300 Making getters by UUID and companyId smarter

Hey Julio,

We have been working on a feature for staging but I've came across a part affecting the web contents, so I'm sending the pull request to you first.

A while ago I've created a method in the *ServiceBaseImpl classes called get/fetchXYByUuidAndCompanyId. The original purpose of this was to be able to fetch the entities like UserGroup or Organization easily during the staging process. But initially I was generated these methods based on if an entity has a uuid and a companyId. By doing so the service builder generated getters and fetchers for JournalArticle/JournalFolder/BookmarksEntry/etc as well. The problem with this is that the get/fetch method is returning a single value only. This is fine if the entity is not in a group but for the journal article we might have multiple articles with the same UUID in the same Company. For a UserGroup this won't happen, but for a JournalArticle it can happen. Since the implementation was missing any OrderByComparator we couldn't know if that's going to return a proper article.

So I've made a fix that makes this smarter. Now for entities like UserGroup it is generating the get/fetch methods as previously, but for grouped entities like JournalArticle it generates a methods which returns lists instead of a single value.

Now here comes your part actually, this was just the introduction :) As I generated the new methods, I was replacing the occurrences to the proper ones, and I've realized that we have duplicated logic for querying an article's layout, and I've reorganized the calls and pulled them into one single place to the JournalUtil, so now every place calls the same method, with the unified logic. Can you please review it? If you think it's good, you can push it to Brian, and I'll add some explanation for him as well.

Thanks,

Máté

cc: @danielkocsis