1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.http;
21  
22  import com.liferay.portal.kernel.json.JSONObject;
23  import com.liferay.portal.service.UserServiceUtil;
24  
25  /**
26   * <a href="UserServiceJSON.java.html"><b><i>View Source</i></b></a>
27   *
28   * <p>
29   * ServiceBuilder generated this class. Modifications in this class will be
30   * overwritten the next time is generated.
31   * </p>
32   *
33   * <p>
34   * This class provides a JSON utility for the
35   * <code>com.liferay.portal.service.UserServiceUtil</code>
36   * service utility. The static methods of this class calls the same methods of
37   * the service utility. However, the signatures are different because it is
38   * difficult for JSON to support certain types.
39   * </p>
40   *
41   * <p>
42   * ServiceBuilder follows certain rules in translating the methods. For example,
43   * if the method in the service utility returns a <code>java.util.List</code>,
44   * that is translated to a
45   * <code>com.liferay.portal.kernel.json.JSONArray</code>. If the method in the
46   * service utility returns a <code>com.liferay.portal.model.User</code>,
47   * that is translated to a
48   * <code>com.liferay.portal.kernel.json.JSONObject</code>. Methods that JSON
49   * cannot safely use are skipped. The logic for the translation is encapsulated
50   * in <code>com.liferay.portal.service.http.UserJSONSerializer</code>.
51   * </p>
52   *
53   * <p>
54   * This allows you to call the the backend services directly from JavaScript.
55   * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
56   * reference of how that portlet uses the generated JavaScript in
57   * <code>portal-web/docroot/html/js/service.js</code> to call the backend
58   * services directly from JavaScript.
59   * </p>
60   *
61   * <p>
62   * The JSON utility is only generated for remote services.
63   * </p>
64   *
65   * @author Brian Wing Shun Chan
66   *
67   * @see com.liferay.portal.service.UserServiceUtil
68   * @see com.liferay.portal.service.http.UserJSONSerializer
69   *
70   */
71  public class UserServiceJSON {
72      public static void addGroupUsers(long groupId, long[] userIds)
73          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
74              com.liferay.portal.SystemException {
75          UserServiceUtil.addGroupUsers(groupId, userIds);
76      }
77  
78      public static void addOrganizationUsers(long organizationId, long[] userIds)
79          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
80              com.liferay.portal.SystemException {
81          UserServiceUtil.addOrganizationUsers(organizationId, userIds);
82      }
83  
84      public static void addPasswordPolicyUsers(long passwordPolicyId,
85          long[] userIds)
86          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
87              com.liferay.portal.SystemException {
88          UserServiceUtil.addPasswordPolicyUsers(passwordPolicyId, userIds);
89      }
90  
91      public static void addRoleUsers(long roleId, long[] userIds)
92          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
93              com.liferay.portal.SystemException {
94          UserServiceUtil.addRoleUsers(roleId, userIds);
95      }
96  
97      public static void addUserGroupUsers(long userGroupId, long[] userIds)
98          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
99              com.liferay.portal.SystemException {
100         UserServiceUtil.addUserGroupUsers(userGroupId, userIds);
101     }
102 
103     public static JSONObject addUser(long companyId, boolean autoPassword,
104         java.lang.String password1, java.lang.String password2,
105         boolean autoScreenName, java.lang.String screenName,
106         java.lang.String emailAddress, String locale,
107         java.lang.String firstName, java.lang.String middleName,
108         java.lang.String lastName, int prefixId, int suffixId, boolean male,
109         int birthdayMonth, int birthdayDay, int birthdayYear,
110         java.lang.String jobTitle, long[] organizationIds, boolean sendEmail)
111         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
112             com.liferay.portal.SystemException {
113         com.liferay.portal.model.User returnValue = UserServiceUtil.addUser(companyId,
114                 autoPassword, password1, password2, autoScreenName, screenName,
115                 emailAddress, new java.util.Locale(locale), firstName,
116                 middleName, lastName, prefixId, suffixId, male, birthdayMonth,
117                 birthdayDay, birthdayYear, jobTitle, organizationIds, sendEmail);
118 
119         return UserJSONSerializer.toJSONObject(returnValue);
120     }
121 
122     public static void deleteRoleUser(long roleId, long userId)
123         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
124             com.liferay.portal.SystemException {
125         UserServiceUtil.deleteRoleUser(roleId, userId);
126     }
127 
128     public static void deleteUser(long userId)
129         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
130             com.liferay.portal.SystemException {
131         UserServiceUtil.deleteUser(userId);
132     }
133 
134     public static long getDefaultUserId(long companyId)
135         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
136             com.liferay.portal.SystemException {
137         long returnValue = UserServiceUtil.getDefaultUserId(companyId);
138 
139         return returnValue;
140     }
141 
142     public static long[] getGroupUserIds(long groupId)
143         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
144         long[] returnValue = UserServiceUtil.getGroupUserIds(groupId);
145 
146         return returnValue;
147     }
148 
149     public static long[] getOrganizationUserIds(long organizationId)
150         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
151         long[] returnValue = UserServiceUtil.getOrganizationUserIds(organizationId);
152 
153         return returnValue;
154     }
155 
156     public static long[] getRoleUserIds(long roleId)
157         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
158         long[] returnValue = UserServiceUtil.getRoleUserIds(roleId);
159 
160         return returnValue;
161     }
162 
163     public static JSONObject getUserByEmailAddress(long companyId,
164         java.lang.String emailAddress)
165         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
166             com.liferay.portal.SystemException {
167         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserByEmailAddress(companyId,
168                 emailAddress);
169 
170         return UserJSONSerializer.toJSONObject(returnValue);
171     }
172 
173     public static JSONObject getUserById(long userId)
174         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
175             com.liferay.portal.SystemException {
176         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserById(userId);
177 
178         return UserJSONSerializer.toJSONObject(returnValue);
179     }
180 
181     public static JSONObject getUserByScreenName(long companyId,
182         java.lang.String screenName)
183         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
184             com.liferay.portal.SystemException {
185         com.liferay.portal.model.User returnValue = UserServiceUtil.getUserByScreenName(companyId,
186                 screenName);
187 
188         return UserJSONSerializer.toJSONObject(returnValue);
189     }
190 
191     public static long getUserIdByEmailAddress(long companyId,
192         java.lang.String emailAddress)
193         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
194             com.liferay.portal.SystemException {
195         long returnValue = UserServiceUtil.getUserIdByEmailAddress(companyId,
196                 emailAddress);
197 
198         return returnValue;
199     }
200 
201     public static long getUserIdByScreenName(long companyId,
202         java.lang.String screenName)
203         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
204             com.liferay.portal.SystemException {
205         long returnValue = UserServiceUtil.getUserIdByScreenName(companyId,
206                 screenName);
207 
208         return returnValue;
209     }
210 
211     public static boolean hasGroupUser(long groupId, long userId)
212         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
213         boolean returnValue = UserServiceUtil.hasGroupUser(groupId, userId);
214 
215         return returnValue;
216     }
217 
218     public static boolean hasRoleUser(long roleId, long userId)
219         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
220         boolean returnValue = UserServiceUtil.hasRoleUser(roleId, userId);
221 
222         return returnValue;
223     }
224 
225     public static void setRoleUsers(long roleId, long[] userIds)
226         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
227             com.liferay.portal.SystemException {
228         UserServiceUtil.setRoleUsers(roleId, userIds);
229     }
230 
231     public static void setUserGroupUsers(long userGroupId, long[] userIds)
232         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
233             com.liferay.portal.SystemException {
234         UserServiceUtil.setUserGroupUsers(userGroupId, userIds);
235     }
236 
237     public static void unsetGroupUsers(long groupId, long[] userIds)
238         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
239             com.liferay.portal.SystemException {
240         UserServiceUtil.unsetGroupUsers(groupId, userIds);
241     }
242 
243     public static void unsetOrganizationUsers(long organizationId,
244         long[] userIds)
245         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
246             com.liferay.portal.SystemException {
247         UserServiceUtil.unsetOrganizationUsers(organizationId, userIds);
248     }
249 
250     public static void unsetPasswordPolicyUsers(long passwordPolicyId,
251         long[] userIds)
252         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
253             com.liferay.portal.SystemException {
254         UserServiceUtil.unsetPasswordPolicyUsers(passwordPolicyId, userIds);
255     }
256 
257     public static void unsetRoleUsers(long roleId, long[] userIds)
258         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
259             com.liferay.portal.SystemException {
260         UserServiceUtil.unsetRoleUsers(roleId, userIds);
261     }
262 
263     public static void unsetUserGroupUsers(long userGroupId, long[] userIds)
264         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
265             com.liferay.portal.SystemException {
266         UserServiceUtil.unsetUserGroupUsers(userGroupId, userIds);
267     }
268 
269     public static JSONObject updateActive(long userId, boolean active)
270         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
271             com.liferay.portal.SystemException {
272         com.liferay.portal.model.User returnValue = UserServiceUtil.updateActive(userId,
273                 active);
274 
275         return UserJSONSerializer.toJSONObject(returnValue);
276     }
277 
278     public static JSONObject updateAgreedToTermsOfUse(long userId,
279         boolean agreedToTermsOfUse)
280         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
281             com.liferay.portal.SystemException {
282         com.liferay.portal.model.User returnValue = UserServiceUtil.updateAgreedToTermsOfUse(userId,
283                 agreedToTermsOfUse);
284 
285         return UserJSONSerializer.toJSONObject(returnValue);
286     }
287 
288     public static JSONObject updateLockout(long userId, boolean lockout)
289         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
290             com.liferay.portal.SystemException {
291         com.liferay.portal.model.User returnValue = UserServiceUtil.updateLockout(userId,
292                 lockout);
293 
294         return UserJSONSerializer.toJSONObject(returnValue);
295     }
296 
297     public static void updateOpenId(long userId, java.lang.String openId)
298         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
299             com.liferay.portal.SystemException {
300         UserServiceUtil.updateOpenId(userId, openId);
301     }
302 
303     public static void updateOrganizations(long userId, long[] organizationIds)
304         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
305             com.liferay.portal.SystemException {
306         UserServiceUtil.updateOrganizations(userId, organizationIds);
307     }
308 
309     public static JSONObject updatePassword(long userId,
310         java.lang.String password1, java.lang.String password2,
311         boolean passwordReset)
312         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
313             com.liferay.portal.SystemException {
314         com.liferay.portal.model.User returnValue = UserServiceUtil.updatePassword(userId,
315                 password1, password2, passwordReset);
316 
317         return UserJSONSerializer.toJSONObject(returnValue);
318     }
319 
320     public static void updatePortrait(long userId, byte[] bytes)
321         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
322             com.liferay.portal.SystemException {
323         UserServiceUtil.updatePortrait(userId, bytes);
324     }
325 
326     public static void updateScreenName(long userId, java.lang.String screenName)
327         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
328             com.liferay.portal.SystemException {
329         UserServiceUtil.updateScreenName(userId, screenName);
330     }
331 
332     public static JSONObject updateUser(long userId,
333         java.lang.String oldPassword, boolean passwordReset,
334         java.lang.String screenName, java.lang.String emailAddress,
335         java.lang.String languageId, java.lang.String timeZoneId,
336         java.lang.String greeting, java.lang.String comments,
337         java.lang.String firstName, java.lang.String middleName,
338         java.lang.String lastName, int prefixId, int suffixId, boolean male,
339         int birthdayMonth, int birthdayDay, int birthdayYear,
340         java.lang.String smsSn, java.lang.String aimSn,
341         java.lang.String facebookSn, java.lang.String icqSn,
342         java.lang.String jabberSn, java.lang.String msnSn,
343         java.lang.String mySpaceSn, java.lang.String skypeSn,
344         java.lang.String twitterSn, java.lang.String ymSn,
345         java.lang.String jobTitle, long[] organizationIds)
346         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
347             com.liferay.portal.SystemException {
348         com.liferay.portal.model.User returnValue = UserServiceUtil.updateUser(userId,
349                 oldPassword, passwordReset, screenName, emailAddress,
350                 languageId, timeZoneId, greeting, comments, firstName,
351                 middleName, lastName, prefixId, suffixId, male, birthdayMonth,
352                 birthdayDay, birthdayYear, smsSn, aimSn, facebookSn, icqSn,
353                 jabberSn, msnSn, mySpaceSn, skypeSn, twitterSn, ymSn, jobTitle,
354                 organizationIds);
355 
356         return UserJSONSerializer.toJSONObject(returnValue);
357     }
358 
359     public static JSONObject updateUser(long userId,
360         java.lang.String oldPassword, java.lang.String newPassword1,
361         java.lang.String newPassword2, boolean passwordReset,
362         java.lang.String screenName, java.lang.String emailAddress,
363         java.lang.String languageId, java.lang.String timeZoneId,
364         java.lang.String greeting, java.lang.String comments,
365         java.lang.String firstName, java.lang.String middleName,
366         java.lang.String lastName, int prefixId, int suffixId, boolean male,
367         int birthdayMonth, int birthdayDay, int birthdayYear,
368         java.lang.String smsSn, java.lang.String aimSn,
369         java.lang.String facebookSn, java.lang.String icqSn,
370         java.lang.String jabberSn, java.lang.String msnSn,
371         java.lang.String mySpaceSn, java.lang.String skypeSn,
372         java.lang.String twitterSn, java.lang.String ymSn,
373         java.lang.String jobTitle, long[] organizationIds)
374         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
375             com.liferay.portal.SystemException {
376         com.liferay.portal.model.User returnValue = UserServiceUtil.updateUser(userId,
377                 oldPassword, newPassword1, newPassword2, passwordReset,
378                 screenName, emailAddress, languageId, timeZoneId, greeting,
379                 comments, firstName, middleName, lastName, prefixId, suffixId,
380                 male, birthdayMonth, birthdayDay, birthdayYear, smsSn, aimSn,
381                 facebookSn, icqSn, jabberSn, msnSn, mySpaceSn, skypeSn,
382                 twitterSn, ymSn, jobTitle, organizationIds);
383 
384         return UserJSONSerializer.toJSONObject(returnValue);
385     }
386 }