77
88import com .liferay .account .constants .AccountConstants ;
99import com .liferay .account .model .AccountEntry ;
10- import com .liferay .account .model .AccountEntryOrganizationRel ;
11- import com .liferay .account .model .AccountEntryUserRel ;
1210import com .liferay .account .service .AccountEntryOrganizationRelLocalServiceUtil ;
1311import com .liferay .account .service .AccountEntryUserRelLocalServiceUtil ;
12+ import com .liferay .petra .function .transform .TransformUtil ;
1413import com .liferay .portal .kernel .exception .PortalException ;
1514import com .liferay .portal .kernel .log .Log ;
1615import com .liferay .portal .kernel .log .LogFactoryUtil ;
3231import com .liferay .portal .kernel .service .WebsiteLocalServiceUtil ;
3332import com .liferay .portal .kernel .util .StringUtil ;
3433
35- import java .util .ArrayList ;
3634import java .util .List ;
3735
3836/**
@@ -56,42 +54,36 @@ public Contact fetchContact() throws PortalException {
5654
5755 @ Override
5856 public List <Organization > fetchOrganizations () {
59- List <Organization > organizations = new ArrayList <>();
60-
61- for (AccountEntryOrganizationRel accountEntryOrganizationRel :
62- AccountEntryOrganizationRelLocalServiceUtil .
63- getAccountEntryOrganizationRels (getAccountEntryId ())) {
64-
65- try {
66- organizations .add (
67- accountEntryOrganizationRel .getOrganization ());
68- }
69- catch (PortalException portalException ) {
70- _log .error (portalException );
71- }
72- }
57+ return TransformUtil .transform (
58+ AccountEntryOrganizationRelLocalServiceUtil .
59+ getAccountEntryOrganizationRels (getAccountEntryId ()),
60+ accountEntryOrganizationRel -> {
61+ try {
62+ return accountEntryOrganizationRel .getOrganization ();
63+ }
64+ catch (PortalException portalException ) {
65+ _log .error (portalException );
7366
74- return organizations ;
67+ return null ;
68+ }
69+ });
7570 }
7671
7772 @ Override
7873 public List <User > fetchUsers () {
79- List <User > users = new ArrayList <>();
80-
81- for (AccountEntryUserRel accountEntryUserRel :
82- AccountEntryUserRelLocalServiceUtil .
83- getAccountEntryUserRelsByAccountEntryId (
84- getAccountEntryId ())) {
85-
86- try {
87- users .add (accountEntryUserRel .getUser ());
88- }
89- catch (PortalException portalException ) {
90- _log .error (portalException );
91- }
92- }
93-
94- return users ;
74+ return TransformUtil .transform (
75+ AccountEntryUserRelLocalServiceUtil .
76+ getAccountEntryUserRelsByAccountEntryId (getAccountEntryId ()),
77+ accountEntryUserRel -> {
78+ try {
79+ return accountEntryUserRel .getUser ();
80+ }
81+ catch (PortalException portalException ) {
82+ _log .error (portalException );
83+
84+ return null ;
85+ }
86+ });
9587 }
9688
9789 @ Override
0 commit comments