LRP-614 practice question 12 of 25

The method to retrieve a list of users added directly to an organization is:

Full set: 144 questions
Answer options
A: OrganizationLocalServiceUtil.getOrganizationUsers()
B: UserLocalServiceUtil.getOrganizationUsers() Correct answer
C: GroupLocalServiceUtil.getOrganizationUsers()
D: All of the above
Correct Answer:
B. UserLocalServiceUtil.getOrganizationUsers()
Explanation

In Liferay's service-oriented architecture, the service utility class corresponding to the primary entity being retrieved is the most appropriate one to use. Since the goal is to retrieve a list of User objects, UserLocalServiceUtil is the correct service. The method getOrganizationUsers(long organizationId) is specifically designed for this purpose, fetching all users directly assigned to the specified organization. While other services might offer convenience wrappers, the core implementation and the most direct API call resides within the UserLocalService.

Why Incorrect

A. While OrganizationLocalServiceUtil.getOrganizationUsers() exists, it is a convenience method that internally delegates the call to UserLocalServiceUtil, making B the more direct and primary choice.
C. The GroupLocalServiceUtil class does not have a method named getOrganizationUsers(). Its methods operate on generic Group entities, not specifically organizations.
D. This option is incorrect because option C is invalid, and option A is a less direct method than the primary implementation found in option B.

References

1. Liferay Portal 6.1 CE Javadocs, com.liferay.portal.service.UserLocalService interface. The documentation specifies the method getOrganizationUsers(long organizationId) which returns the list of users associated with the organization. This is the primary service for user-related operations. (Reference: com.liferay.portal.service.UserLocalService#getOrganizationUsers(long))

2. Liferay Portal 6.1 CE Javadocs, com.liferay.portal.service.OrganizationLocalService interface. The documentation for getOrganizationUsers(long organizationId) in this service often indicates that it is a wrapper. The source code for its implementation (OrganizationLocalServiceImpl) confirms it delegates the call directly to userLocalService.getOrganizationUsers(organizationId). (Reference: com.liferay.portal.service.OrganizationLocalService#getOrganizationUsers(long))

3. Liferay Portal 6.1 CE Javadocs, com.liferay.portal.service.GroupLocalService interface. A review of this service's API shows the absence of a getOrganizationUsers method, confirming that option C is invalid. (Reference: com.liferay.portal.service.GroupLocalService API documentation).

Scroll to Top