1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.http;
24  
25  import com.liferay.portal.kernel.json.JSONObject;
26  import com.liferay.portal.service.UserServiceUtil;
27  
28  /**
29   * <a href="UserServiceJSON.java.html"><b><i>View Source</i></b></a>
30   *
31   * <p>
32   * ServiceBuilder generated this class. Modifications in this class will be
33   * overwritten the next time is generated.
34   * </p>
35   *
36   * <p>
37   * This class provides a JSON utility for the
38   * <code>com.liferay.portal.service.UserServiceUtil</code>
39   * service utility. The static methods of this class calls the same methods of
40   * the service utility. However, the signatures are different because it is
41   * difficult for JSON to support certain types.
42   * </p>
43   *
44   * <p>
45   * ServiceBuilder follows certain rules in translating the methods. For example,
46   * if the method in the service utility returns a <code>java.util.List</code>,
47   * that is translated to a
48   * <code>com.liferay.portal.kernel.json.JSONArray</code>. If the method in the
49   * service utility returns a <code>com.liferay.portal.model.User</code>,
50   * that is translated to a
51   * <code>com.liferay.portal.kernel.json.JSONObject</code>. Methods that JSON
52   * cannot safely use are skipped. The logic for the translation is encapsulated
53   * in <code>com.liferay.portal.service.http.UserJSONSerializer</code>.
54   * </p>
55   *
56   * <p>
57   * This allows you to call the the backend services directly from JavaScript.
58   * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
59   * reference of how that portlet uses the generated JavaScript in
60   * <code>portal-web/docroot/html/js/service.js</code> to call the backend
61   * services directly from JavaScript.
62   * </p>
63   *
64   * <p>
65   * The JSON utility is only generated for remote services.
66   * </p>
67   *
68   * @author Brian Wing Shun Chan
69   *
70   * @see com.liferay.portal.service.UserServiceUtil
71   * @see com.liferay.portal.service.http.UserJSONSerializer
72   *
73   */
74  public class UserServiceJSON {
75      public static void addGroupUsers(long groupId, long[] userIds)
76          throws com.liferay.portal.PortalException,
77              com.liferay.portal.SystemException {
78          UserServiceUtil.addGroupUsers(groupId, userIds);
79      }
80  
81      public static void addOrganizationUsers(long organizationId, long[] userIds)
82          throws com.liferay.portal.PortalException,
83              com.liferay.portal.SystemException {
84          UserServiceUtil.addOrganizationUsers(organizationId, userIds);
85      }
86  
87      public static void addPasswordPolicyUsers(long passwordPolicyId,
88          long[] userIds)
89          throws com.liferay.portal.PortalException,
90              com.liferay.portal.SystemException {
91          UserServiceUtil.addPasswordPolicyUsers(passwordPolicyId, userIds);
92      }
93  
94      public static void addRoleUsers(long roleId, long[] userIds)
95          throws com.liferay.portal.PortalException,
96              com.liferay.portal.SystemException {
97          UserServiceUtil.addRoleUsers(roleId, userIds);
98      }
99  
100     public static void addUserGroupUsers(long userGroupId, long[] userIds)
101         throws com.liferay.portal.PortalException,
102             com.liferay.portal.SystemException {
103         UserServiceUtil.addUserGroupUsers(userGroupId, userIds);
104     }
105 
106     public static JSONObject addUser(long companyId, boolean autoPassword,
107         java.lang.String password1, java.lang.String password2,
108         boolean autoScreenName, java.lang.String screenName,
109         java.lang.String emailAddress, java.lang.String openId, String locale,
110         java.lang.String firstName, java.lang.String middleName,
111         java.lang.String lastName, int prefixId, int suffixId, boolean male,
112         int birthdayMonth, int birthdayDay, int birthdayYear,
113         java.lang.String jobTitle, long[] groupIds, long[] organizationIds,
114         long[] roleIds, long[] userGroupIds, boolean sendEmail,
115         com.liferay.portal.service.ServiceContext serviceContext)
116         throws com.liferay.portal.PortalException,
117             com.liferay.portal.SystemException {
118         com.liferay.portal.model.User returnValue = UserServiceUtil.addUser(companyId,
119                 autoPassword, password1, password2, autoScreenName, screenName,
120                 emailAddress, openId, new java.util.Locale(locale), firstName,
121                 middleName, lastName, prefixId, suffixId, male, birthdayMonth,
122                 birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds,
123                 roleIds, userGroupIds, sendEmail, serviceContext);
124 
125         return UserJSONSerializer.toJSONObject(returnValue);
126     }
127 
128     public static JSONObject addUser(long companyId, boolean autoPassword,
129         java.lang.String password1, java.lang.String password2,
130         boolean autoScreenName, java.lang.String screenName,
131         java.lang.String emailAddress, java.lang.String openId, String locale,
132         java.lang.String firstName, java.lang.String middleName,
133         java.lang.String lastName, int prefixId, int suffixId, boolean male,
134         int birthdayMonth, int birthdayDay, int birthdayYear,
135         java.lang.String jobTitle, long[] groupIds, long[] organizationIds,
136         long[] roleIds, long[] userGroupIds, boolean sendEmail,
137         java.util.List<com.liferay.portal.model.Address> addresses,
138         java.util.List<com.liferay.portal.model.EmailAddress> emailAddresses,
139         java.util.List<com.liferay.portal.model.Phone> phones,
140         java.util.List<com.liferay.portal.model.Website> websites,
141         java.util.List<com.liferay.portlet.announcements.model.AnnouncementsDelivery> announcementsDelivers,
142         com.liferay.portal.service.ServiceContext serviceContext)
143         throws com.liferay.portal.PortalException,
144             com.liferay.portal.SystemException {
145         com.liferay.portal.model.User returnValue = UserServiceUtil.addUser(companyId,
146                 autoPassword, password1, password2, autoScreenName, screenName,
147                 emailAddress, openId, new java.util.Locale(locale), firstName,
148                 middleName, lastName, prefixId, suffixId, male, birthdayMonth,
149                 birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds,
150                 roleIds, userGroupIds, sendEmail, addresses, emailAddresses,
151                 phones, websites, announcementsDelivers, serviceContext);
152 
153         return UserJSONSerializer.toJSONObject(returnValue);
154     }
155 
156     public static void deletePortrait(long userId)
157         throws com.liferay.portal.PortalException,
158             com.liferay.portal.SystemException {
159         UserServiceUtil.deletePortrait(userId);
160     }
161 
162     public static void deleteRoleUser(long roleId, long userId)
163         throws com.liferay.portal.PortalException,
164             com.liferay.portal.SystemException {
165         UserServiceUtil.deleteRoleUser(roleId, userId);
166     }
167 
168     public static void deleteUser(long userId)
169         throws com.liferay.portal.PortalException,
170             com.liferay.portal.SystemException {
171         UserServiceUtil.deleteUser(userId);
172     }
173 
174     public static long getDefaultUserId(long companyId)
175         throws com.liferay.portal.PortalException,
176             com.liferay.portal.SystemException {
177         long returnValue = UserServiceUtil.getDefaultUserId(companyId);
178 
179         return returnValue;
180     }
181 
182     public static long[] getGroupUserIds(long groupId)
183         throws com.liferay.portal.SystemException {
184         long[] returnValue = UserServiceUtil.getGroupUserIds(groupId);
185 
186         return returnValue;
187     }
188 
189     public static long[] getOrganizationUserIds(long organizationId)
190         throws com.liferay.portal.SystemException {
191         long[] returnValue = UserServiceUtil.getOrganizationUserIds(organizationId);
192 
193         return returnValue;
194     }
195 
196     public static long[] getRoleUserIds(long roleId)
197         throws com.liferay.portal.SystemException {
198         long[] returnValue = UserServiceUtil.getRoleUserIds(roleId);
199 
200         return returnValue;
201     }
202 
203     public static JSONObject getUserByEmailAddress(long companyId,
204         java.lang.String emailAddress)
205         throws com.liferay.portal.PortalException,
206             com.liferay.portal.SystemException {
207         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserByEmailAddress(companyId,
208                 emailAddress);
209 
210         return UserJSONSerializer.toJSONObject(returnValue);
211     }
212 
213     public static JSONObject getUserById(long userId)
214         throws com.liferay.portal.PortalException,
215             com.liferay.portal.SystemException {
216         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserById(userId);
217 
218         return UserJSONSerializer.toJSONObject(returnValue);
219     }
220 
221     public static JSONObject getUserByScreenName(long companyId,
222         java.lang.String screenName)
223         throws com.liferay.portal.PortalException,
224             com.liferay.portal.SystemException {
225         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserByScreenName(companyId,
226                 screenName);
227 
228         return UserJSONSerializer.toJSONObject(returnValue);
229     }
230 
231     public static long getUserIdByEmailAddress(long companyId,
232         java.lang.String emailAddress)
233         throws com.liferay.portal.PortalException,
234             com.liferay.portal.SystemException {
235         long returnValue = UserServiceUtil.getUserIdByEmailAddress(companyId,
236                 emailAddress);
237 
238         return returnValue;
239     }
240 
241     public static long getUserIdByScreenName(long companyId,
242         java.lang.String screenName)
243         throws com.liferay.portal.PortalException,
244             com.liferay.portal.SystemException {
245         long returnValue = UserServiceUtil.getUserIdByScreenName(companyId,
246                 screenName);
247 
248         return returnValue;
249     }
250 
251     public static boolean hasGroupUser(long groupId, long userId)
252         throws com.liferay.portal.SystemException {
253         boolean returnValue = UserServiceUtil.hasGroupUser(groupId, userId);
254 
255         return returnValue;
256     }
257 
258     public static boolean hasRoleUser(long roleId, long userId)
259         throws com.liferay.portal.SystemException {
260         boolean returnValue = UserServiceUtil.hasRoleUser(roleId, userId);
261 
262         return returnValue;
263     }
264 
265     public static void setRoleUsers(long roleId, long[] userIds)
266         throws com.liferay.portal.PortalException,
267             com.liferay.portal.SystemException {
268         UserServiceUtil.setRoleUsers(roleId, userIds);
269     }
270 
271     public static void setUserGroupUsers(long userGroupId, long[] userIds)
272         throws com.liferay.portal.PortalException,
273             com.liferay.portal.SystemException {
274         UserServiceUtil.setUserGroupUsers(userGroupId, userIds);
275     }
276 
277     public static void unsetGroupUsers(long groupId, long[] userIds)
278         throws com.liferay.portal.PortalException,
279             com.liferay.portal.SystemException {
280         UserServiceUtil.unsetGroupUsers(groupId, userIds);
281     }
282 
283     public static void unsetOrganizationUsers(long organizationId,
284         long[] userIds)
285         throws com.liferay.portal.PortalException,
286             com.liferay.portal.SystemException {
287         UserServiceUtil.unsetOrganizationUsers(organizationId, userIds);
288     }
289 
290     public static void unsetPasswordPolicyUsers(long passwordPolicyId,
291         long[] userIds)
292         throws com.liferay.portal.PortalException,
293             com.liferay.portal.SystemException {
294         UserServiceUtil.unsetPasswordPolicyUsers(passwordPolicyId, userIds);
295     }
296 
297     public static void unsetRoleUsers(long roleId, long[] userIds)
298         throws com.liferay.portal.PortalException,
299             com.liferay.portal.SystemException {
300         UserServiceUtil.unsetRoleUsers(roleId, userIds);
301     }
302 
303     public static void unsetUserGroupUsers(long userGroupId, long[] userIds)
304         throws com.liferay.portal.PortalException,
305             com.liferay.portal.SystemException {
306         UserServiceUtil.unsetUserGroupUsers(userGroupId, userIds);
307     }
308 
309     public static JSONObject updateActive(long userId, boolean active)
310         throws com.liferay.portal.PortalException,
311             com.liferay.portal.SystemException {
312         com.liferay.portal.model.User returnValue = UserServiceUtil.updateActive(userId,
313                 active);
314 
315         return UserJSONSerializer.toJSONObject(returnValue);
316     }
317 
318     public static JSONObject updateAgreedToTermsOfUse(long userId,
319         boolean agreedToTermsOfUse)
320         throws com.liferay.portal.PortalException,
321             com.liferay.portal.SystemException {
322         com.liferay.portal.model.User returnValue = UserServiceUtil.updateAgreedToTermsOfUse(userId,
323                 agreedToTermsOfUse);
324 
325         return UserJSONSerializer.toJSONObject(returnValue);
326     }
327 
328     public static void updateEmailAddress(long userId,
329         java.lang.String password, java.lang.String emailAddress1,
330         java.lang.String emailAddress2)
331         throws com.liferay.portal.PortalException,
332             com.liferay.portal.SystemException {
333         UserServiceUtil.updateEmailAddress(userId, password, emailAddress1,
334             emailAddress2);
335     }
336 
337     public static JSONObject updateLockout(long userId, boolean lockout)
338         throws com.liferay.portal.PortalException,
339             com.liferay.portal.SystemException {
340         com.liferay.portal.model.User returnValue = UserServiceUtil.updateLockout(userId,
341                 lockout);
342 
343         return UserJSONSerializer.toJSONObject(returnValue);
344     }
345 
346     public static void updateOpenId(long userId, java.lang.String openId)
347         throws com.liferay.portal.PortalException,
348             com.liferay.portal.SystemException {
349         UserServiceUtil.updateOpenId(userId, openId);
350     }
351 
352     public static void updateOrganizations(long userId, long[] organizationIds)
353         throws com.liferay.portal.PortalException,
354             com.liferay.portal.SystemException {
355         UserServiceUtil.updateOrganizations(userId, organizationIds);
356     }
357 
358     public static JSONObject updatePassword(long userId,
359         java.lang.String password1, java.lang.String password2,
360         boolean passwordReset)
361         throws com.liferay.portal.PortalException,
362             com.liferay.portal.SystemException {
363         com.liferay.portal.model.User returnValue = UserServiceUtil.updatePassword(userId,
364                 password1, password2, passwordReset);
365 
366         return UserJSONSerializer.toJSONObject(returnValue);
367     }
368 
369     public static void updatePortrait(long userId, byte[] bytes)
370         throws com.liferay.portal.PortalException,
371             com.liferay.portal.SystemException {
372         UserServiceUtil.updatePortrait(userId, bytes);
373     }
374 
375     public static void updateReminderQuery(long userId,
376         java.lang.String question, java.lang.String answer)
377         throws com.liferay.portal.PortalException,
378             com.liferay.portal.SystemException {
379         UserServiceUtil.updateReminderQuery(userId, question, answer);
380     }
381 
382     public static void updateScreenName(long userId, java.lang.String screenName)
383         throws com.liferay.portal.PortalException,
384             com.liferay.portal.SystemException {
385         UserServiceUtil.updateScreenName(userId, screenName);
386     }
387 
388     public static JSONObject updateUser(long userId,
389         java.lang.String oldPassword, java.lang.String newPassword1,
390         java.lang.String newPassword2, boolean passwordReset,
391         java.lang.String reminderQueryQuestion,
392         java.lang.String reminderQueryAnswer, java.lang.String screenName,
393         java.lang.String emailAddress, java.lang.String openId,
394         java.lang.String languageId, java.lang.String timeZoneId,
395         java.lang.String greeting, java.lang.String comments,
396         java.lang.String firstName, java.lang.String middleName,
397         java.lang.String lastName, int prefixId, int suffixId, boolean male,
398         int birthdayMonth, int birthdayDay, int birthdayYear,
399         java.lang.String smsSn, java.lang.String aimSn,
400         java.lang.String facebookSn, java.lang.String icqSn,
401         java.lang.String jabberSn, java.lang.String msnSn,
402         java.lang.String mySpaceSn, java.lang.String skypeSn,
403         java.lang.String twitterSn, java.lang.String ymSn,
404         java.lang.String jobTitle, long[] groupIds, long[] organizationIds,
405         long[] roleIds,
406         java.util.List<com.liferay.portal.model.UserGroupRole> userGroupRoles,
407         long[] userGroupIds,
408         com.liferay.portal.service.ServiceContext serviceContext)
409         throws com.liferay.portal.PortalException,
410             com.liferay.portal.SystemException {
411         com.liferay.portal.model.User returnValue = UserServiceUtil.updateUser(userId,
412                 oldPassword, newPassword1, newPassword2, passwordReset,
413                 reminderQueryQuestion, reminderQueryAnswer, screenName,
414                 emailAddress, openId, languageId, timeZoneId, greeting,
415                 comments, firstName, middleName, lastName, prefixId, suffixId,
416                 male, birthdayMonth, birthdayDay, birthdayYear, smsSn, aimSn,
417                 facebookSn, icqSn, jabberSn, msnSn, mySpaceSn, skypeSn,
418                 twitterSn, ymSn, jobTitle, groupIds, organizationIds, roleIds,
419                 userGroupRoles, userGroupIds, serviceContext);
420 
421         return UserJSONSerializer.toJSONObject(returnValue);
422     }
423 
424     public static JSONObject updateUser(long userId,
425         java.lang.String oldPassword, java.lang.String newPassword1,
426         java.lang.String newPassword2, boolean passwordReset,
427         java.lang.String reminderQueryQuestion,
428         java.lang.String reminderQueryAnswer, java.lang.String screenName,
429         java.lang.String emailAddress, java.lang.String openId,
430         java.lang.String languageId, java.lang.String timeZoneId,
431         java.lang.String greeting, java.lang.String comments,
432         java.lang.String firstName, java.lang.String middleName,
433         java.lang.String lastName, int prefixId, int suffixId, boolean male,
434         int birthdayMonth, int birthdayDay, int birthdayYear,
435         java.lang.String smsSn, java.lang.String aimSn,
436         java.lang.String facebookSn, java.lang.String icqSn,
437         java.lang.String jabberSn, java.lang.String msnSn,
438         java.lang.String mySpaceSn, java.lang.String skypeSn,
439         java.lang.String twitterSn, java.lang.String ymSn,
440         java.lang.String jobTitle, long[] groupIds, long[] organizationIds,
441         long[] roleIds,
442         java.util.List<com.liferay.portal.model.UserGroupRole> userGroupRoles,
443         long[] userGroupIds,
444         java.util.List<com.liferay.portal.model.Address> addresses,
445         java.util.List<com.liferay.portal.model.EmailAddress> emailAddresses,
446         java.util.List<com.liferay.portal.model.Phone> phones,
447         java.util.List<com.liferay.portal.model.Website> websites,
448         java.util.List<com.liferay.portlet.announcements.model.AnnouncementsDelivery> announcementsDelivers,
449         com.liferay.portal.service.ServiceContext serviceContext)
450         throws com.liferay.portal.PortalException,
451             com.liferay.portal.SystemException {
452         com.liferay.portal.model.User returnValue = UserServiceUtil.updateUser(userId,
453                 oldPassword, newPassword1, newPassword2, passwordReset,
454                 reminderQueryQuestion, reminderQueryAnswer, screenName,
455                 emailAddress, openId, languageId, timeZoneId, greeting,
456                 comments, firstName, middleName, lastName, prefixId, suffixId,
457                 male, birthdayMonth, birthdayDay, birthdayYear, smsSn, aimSn,
458                 facebookSn, icqSn, jabberSn, msnSn, mySpaceSn, skypeSn,
459                 twitterSn, ymSn, jobTitle, groupIds, organizationIds, roleIds,
460                 userGroupRoles, userGroupIds, addresses, emailAddresses,
461                 phones, websites, announcementsDelivers, serviceContext);
462 
463         return UserJSONSerializer.toJSONObject(returnValue);
464     }
465 }