1   /**
2    * Copyright (c) 2000-2008 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 java.rmi.RemoteException, 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 java.rmi.RemoteException, 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 java.rmi.RemoteException, 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 java.rmi.RemoteException, 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 java.rmi.RemoteException, 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, 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[] organizationIds, boolean sendEmail)
114         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
115             com.liferay.portal.SystemException {
116         com.liferay.portal.model.User returnValue = UserServiceUtil.addUser(companyId,
117                 autoPassword, password1, password2, autoScreenName, screenName,
118                 emailAddress, new java.util.Locale(locale), firstName,
119                 middleName, lastName, prefixId, suffixId, male, birthdayMonth,
120                 birthdayDay, birthdayYear, jobTitle, organizationIds, sendEmail);
121 
122         return UserJSONSerializer.toJSONObject(returnValue);
123     }
124 
125     public static void deleteRoleUser(long roleId, long userId)
126         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
127             com.liferay.portal.SystemException {
128         UserServiceUtil.deleteRoleUser(roleId, userId);
129     }
130 
131     public static void deleteUser(long userId)
132         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
133             com.liferay.portal.SystemException {
134         UserServiceUtil.deleteUser(userId);
135     }
136 
137     public static long getDefaultUserId(long companyId)
138         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
139             com.liferay.portal.SystemException {
140         long returnValue = UserServiceUtil.getDefaultUserId(companyId);
141 
142         return returnValue;
143     }
144 
145     public static JSONObject getUserByEmailAddress(long companyId,
146         java.lang.String emailAddress)
147         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
148             com.liferay.portal.SystemException {
149         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserByEmailAddress(companyId,
150                 emailAddress);
151 
152         return UserJSONSerializer.toJSONObject(returnValue);
153     }
154 
155     public static JSONObject getUserById(long userId)
156         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
157             com.liferay.portal.SystemException {
158         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserById(userId);
159 
160         return UserJSONSerializer.toJSONObject(returnValue);
161     }
162 
163     public static JSONObject getUserByScreenName(long companyId,
164         java.lang.String screenName)
165         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
166             com.liferay.portal.SystemException {
167         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserByScreenName(companyId,
168                 screenName);
169 
170         return UserJSONSerializer.toJSONObject(returnValue);
171     }
172 
173     public static long getUserIdByEmailAddress(long companyId,
174         java.lang.String emailAddress)
175         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
176             com.liferay.portal.SystemException {
177         long returnValue = UserServiceUtil.getUserIdByEmailAddress(companyId,
178                 emailAddress);
179 
180         return returnValue;
181     }
182 
183     public static long getUserIdByScreenName(long companyId,
184         java.lang.String screenName)
185         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
186             com.liferay.portal.SystemException {
187         long returnValue = UserServiceUtil.getUserIdByScreenName(companyId,
188                 screenName);
189 
190         return returnValue;
191     }
192 
193     public static boolean hasGroupUser(long groupId, long userId)
194         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
195         boolean returnValue = UserServiceUtil.hasGroupUser(groupId, userId);
196 
197         return returnValue;
198     }
199 
200     public static boolean hasRoleUser(long roleId, long userId)
201         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
202         boolean returnValue = UserServiceUtil.hasRoleUser(roleId, userId);
203 
204         return returnValue;
205     }
206 
207     public static void setRoleUsers(long roleId, long[] userIds)
208         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
209             com.liferay.portal.SystemException {
210         UserServiceUtil.setRoleUsers(roleId, userIds);
211     }
212 
213     public static void setUserGroupUsers(long userGroupId, long[] userIds)
214         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
215             com.liferay.portal.SystemException {
216         UserServiceUtil.setUserGroupUsers(userGroupId, userIds);
217     }
218 
219     public static void unsetGroupUsers(long groupId, long[] userIds)
220         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
221             com.liferay.portal.SystemException {
222         UserServiceUtil.unsetGroupUsers(groupId, userIds);
223     }
224 
225     public static void unsetOrganizationUsers(long organizationId,
226         long[] userIds)
227         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
228             com.liferay.portal.SystemException {
229         UserServiceUtil.unsetOrganizationUsers(organizationId, userIds);
230     }
231 
232     public static void unsetPasswordPolicyUsers(long passwordPolicyId,
233         long[] userIds)
234         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
235             com.liferay.portal.SystemException {
236         UserServiceUtil.unsetPasswordPolicyUsers(passwordPolicyId, userIds);
237     }
238 
239     public static void unsetRoleUsers(long roleId, long[] userIds)
240         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
241             com.liferay.portal.SystemException {
242         UserServiceUtil.unsetRoleUsers(roleId, userIds);
243     }
244 
245     public static void unsetUserGroupUsers(long userGroupId, long[] userIds)
246         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
247             com.liferay.portal.SystemException {
248         UserServiceUtil.unsetUserGroupUsers(userGroupId, userIds);
249     }
250 
251     public static JSONObject updateActive(long userId, boolean active)
252         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
253             com.liferay.portal.SystemException {
254         com.liferay.portal.model.User returnValue = UserServiceUtil.updateActive(userId,
255                 active);
256 
257         return UserJSONSerializer.toJSONObject(returnValue);
258     }
259 
260     public static JSONObject updateAgreedToTermsOfUse(long userId,
261         boolean agreedToTermsOfUse)
262         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
263             com.liferay.portal.SystemException {
264         com.liferay.portal.model.User returnValue = UserServiceUtil.updateAgreedToTermsOfUse(userId,
265                 agreedToTermsOfUse);
266 
267         return UserJSONSerializer.toJSONObject(returnValue);
268     }
269 
270     public static JSONObject updateLockout(long userId, boolean lockout)
271         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
272             com.liferay.portal.SystemException {
273         com.liferay.portal.model.User returnValue = UserServiceUtil.updateLockout(userId,
274                 lockout);
275 
276         return UserJSONSerializer.toJSONObject(returnValue);
277     }
278 
279     public static void updateOrganizations(long userId, long[] organizationIds)
280         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
281             com.liferay.portal.SystemException {
282         UserServiceUtil.updateOrganizations(userId, organizationIds);
283     }
284 
285     public static JSONObject updatePassword(long userId,
286         java.lang.String password1, java.lang.String password2,
287         boolean passwordReset)
288         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
289             com.liferay.portal.SystemException {
290         com.liferay.portal.model.User returnValue = UserServiceUtil.updatePassword(userId,
291                 password1, password2, passwordReset);
292 
293         return UserJSONSerializer.toJSONObject(returnValue);
294     }
295 
296     public static void updatePortrait(long userId, byte[] bytes)
297         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
298             com.liferay.portal.SystemException {
299         UserServiceUtil.updatePortrait(userId, bytes);
300     }
301 
302     public static void updateScreenName(long userId, java.lang.String screenName)
303         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
304             com.liferay.portal.SystemException {
305         UserServiceUtil.updateScreenName(userId, screenName);
306     }
307 
308     public static void updateOpenId(long userId, java.lang.String openId)
309         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
310             com.liferay.portal.SystemException {
311         UserServiceUtil.updateOpenId(userId, openId);
312     }
313 
314     public static JSONObject updateUser(long userId,
315         java.lang.String oldPassword, boolean passwordReset,
316         java.lang.String screenName, java.lang.String emailAddress,
317         java.lang.String languageId, java.lang.String timeZoneId,
318         java.lang.String greeting, java.lang.String comments,
319         java.lang.String firstName, java.lang.String middleName,
320         java.lang.String lastName, int prefixId, int suffixId, boolean male,
321         int birthdayMonth, int birthdayDay, int birthdayYear,
322         java.lang.String smsSn, java.lang.String aimSn,
323         java.lang.String facebookSn, java.lang.String icqSn,
324         java.lang.String jabberSn, java.lang.String msnSn,
325         java.lang.String mySpaceSn, java.lang.String skypeSn,
326         java.lang.String twitterSn, java.lang.String ymSn,
327         java.lang.String jobTitle, long[] organizationIds)
328         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
329             com.liferay.portal.SystemException {
330         com.liferay.portal.model.User returnValue = UserServiceUtil.updateUser(userId,
331                 oldPassword, passwordReset, screenName, emailAddress,
332                 languageId, timeZoneId, greeting, comments, firstName,
333                 middleName, lastName, prefixId, suffixId, male, birthdayMonth,
334                 birthdayDay, birthdayYear, smsSn, aimSn, facebookSn, icqSn,
335                 jabberSn, msnSn, mySpaceSn, skypeSn, twitterSn, ymSn, jobTitle,
336                 organizationIds);
337 
338         return UserJSONSerializer.toJSONObject(returnValue);
339     }
340 
341     public static JSONObject updateUser(long userId,
342         java.lang.String oldPassword, java.lang.String newPassword1,
343         java.lang.String newPassword2, boolean passwordReset,
344         java.lang.String screenName, java.lang.String emailAddress,
345         java.lang.String languageId, java.lang.String timeZoneId,
346         java.lang.String greeting, java.lang.String comments,
347         java.lang.String firstName, java.lang.String middleName,
348         java.lang.String lastName, int prefixId, int suffixId, boolean male,
349         int birthdayMonth, int birthdayDay, int birthdayYear,
350         java.lang.String smsSn, java.lang.String aimSn,
351         java.lang.String facebookSn, java.lang.String icqSn,
352         java.lang.String jabberSn, java.lang.String msnSn,
353         java.lang.String mySpaceSn, java.lang.String skypeSn,
354         java.lang.String twitterSn, java.lang.String ymSn,
355         java.lang.String jobTitle, long[] organizationIds)
356         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
357             com.liferay.portal.SystemException {
358         com.liferay.portal.model.User returnValue = UserServiceUtil.updateUser(userId,
359                 oldPassword, newPassword1, newPassword2, passwordReset,
360                 screenName, emailAddress, languageId, timeZoneId, greeting,
361                 comments, firstName, middleName, lastName, prefixId, suffixId,
362                 male, birthdayMonth, birthdayDay, birthdayYear, smsSn, aimSn,
363                 facebookSn, icqSn, jabberSn, msnSn, mySpaceSn, skypeSn,
364                 twitterSn, ymSn, jobTitle, organizationIds);
365 
366         return UserJSONSerializer.toJSONObject(returnValue);
367     }
368 }