001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.http;
022:
023: import com.liferay.portal.service.UserServiceUtil;
024:
025: import org.json.JSONArray;
026: import org.json.JSONObject;
027:
028: /**
029: * <a href="UserServiceJSON.java.html"><b><i>View Source</i></b></a>
030: *
031: * <p>
032: * ServiceBuilder generated this class. Modifications in this class will be
033: * overwritten the next time is generated.
034: * </p>
035: *
036: * <p>
037: * This class provides a JSON utility for the
038: * <code>com.liferay.portal.service.UserServiceUtil</code>
039: * service utility. The static methods of this class calls the same methods of
040: * the service utility. However, the signatures are different because it is
041: * difficult for JSON to support certain types.
042: * </p>
043: *
044: * <p>
045: * ServiceBuilder follows certain rules in translating the methods. For example,
046: * if the method in the service utility returns a <code>java.util.List</code>,
047: * that is translated to a <code>org.json.JSONArray</code>. If the method in the
048: * service utility returns a <code>com.liferay.portal.model.User</code>,
049: * that is translated to a <code>org.json.JSONObject</code>. Methods that JSON
050: * cannot safely use are skipped. The logic for the translation is encapsulated
051: * in <code>com.liferay.portal.service.http.UserJSONSerializer</code>.
052: * </p>
053: *
054: * <p>
055: * This allows you to call the the backend services directly from JavaScript.
056: * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
057: * reference of how that portlet uses the generated JavaScript in
058: * <code>portal-web/docroot/html/js/service.js</code> to call the backend
059: * services directly from JavaScript.
060: * </p>
061: *
062: * <p>
063: * The JSON utility is only generated for remote services.
064: * </p>
065: *
066: * @author Brian Wing Shun Chan
067: *
068: * @see com.liferay.portal.service.UserServiceUtil
069: * @see com.liferay.portal.service.http.UserJSONSerializer
070: *
071: */
072: public class UserServiceJSON {
073: public static void addGroupUsers(long groupId, long[] userIds)
074: throws java.rmi.RemoteException,
075: com.liferay.portal.SystemException,
076: com.liferay.portal.PortalException {
077: UserServiceUtil.addGroupUsers(groupId, userIds);
078: }
079:
080: public static void addOrganizationUsers(long organizationId,
081: long[] userIds) throws java.rmi.RemoteException,
082: com.liferay.portal.SystemException,
083: com.liferay.portal.PortalException {
084: UserServiceUtil.addOrganizationUsers(organizationId, userIds);
085: }
086:
087: public static void addPasswordPolicyUsers(long passwordPolicyId,
088: long[] userIds) throws java.rmi.RemoteException,
089: com.liferay.portal.SystemException,
090: com.liferay.portal.PortalException {
091: UserServiceUtil.addPasswordPolicyUsers(passwordPolicyId,
092: userIds);
093: }
094:
095: public static void addRoleUsers(long roleId, long[] userIds)
096: throws java.rmi.RemoteException,
097: com.liferay.portal.SystemException,
098: com.liferay.portal.PortalException {
099: UserServiceUtil.addRoleUsers(roleId, userIds);
100: }
101:
102: public static void addUserGroupUsers(long userGroupId,
103: long[] userIds) throws java.rmi.RemoteException,
104: com.liferay.portal.SystemException,
105: com.liferay.portal.PortalException {
106: UserServiceUtil.addUserGroupUsers(userGroupId, userIds);
107: }
108:
109: public static JSONObject addUser(long companyId,
110: boolean autoPassword, java.lang.String password1,
111: java.lang.String password2, boolean autoScreenName,
112: java.lang.String screenName, java.lang.String emailAddress,
113: String locale, java.lang.String firstName,
114: java.lang.String middleName, java.lang.String lastName,
115: int prefixId, int suffixId, boolean male,
116: int birthdayMonth, int birthdayDay, int birthdayYear,
117: java.lang.String jobTitle, long[] organizationIds,
118: boolean sendEmail) throws java.rmi.RemoteException,
119: com.liferay.portal.SystemException,
120: com.liferay.portal.PortalException {
121: com.liferay.portal.model.User returnValue = UserServiceUtil
122: .addUser(companyId, autoPassword, password1, password2,
123: autoScreenName, screenName, emailAddress,
124: new java.util.Locale(locale), firstName,
125: middleName, lastName, prefixId, suffixId, male,
126: birthdayMonth, birthdayDay, birthdayYear,
127: jobTitle, organizationIds, sendEmail);
128:
129: return UserJSONSerializer.toJSONObject(returnValue);
130: }
131:
132: public static void deleteRoleUser(long roleId, long userId)
133: throws java.rmi.RemoteException,
134: com.liferay.portal.SystemException,
135: com.liferay.portal.PortalException {
136: UserServiceUtil.deleteRoleUser(roleId, userId);
137: }
138:
139: public static void deleteUser(long userId)
140: throws java.rmi.RemoteException,
141: com.liferay.portal.SystemException,
142: com.liferay.portal.PortalException {
143: UserServiceUtil.deleteUser(userId);
144: }
145:
146: public static long getDefaultUserId(long companyId)
147: throws java.rmi.RemoteException,
148: com.liferay.portal.SystemException,
149: com.liferay.portal.PortalException {
150: long returnValue = UserServiceUtil.getDefaultUserId(companyId);
151:
152: return returnValue;
153: }
154:
155: public static JSONArray getGroupUsers(long groupId)
156: throws java.rmi.RemoteException,
157: com.liferay.portal.SystemException,
158: com.liferay.portal.PortalException {
159: java.util.List returnValue = UserServiceUtil
160: .getGroupUsers(groupId);
161:
162: return UserJSONSerializer.toJSONArray(returnValue);
163: }
164:
165: public static JSONArray getRoleUsers(long roleId)
166: throws java.rmi.RemoteException,
167: com.liferay.portal.SystemException,
168: com.liferay.portal.PortalException {
169: java.util.List returnValue = UserServiceUtil
170: .getRoleUsers(roleId);
171:
172: return UserJSONSerializer.toJSONArray(returnValue);
173: }
174:
175: public static JSONObject getUserByEmailAddress(long companyId,
176: java.lang.String emailAddress)
177: throws java.rmi.RemoteException,
178: com.liferay.portal.SystemException,
179: com.liferay.portal.PortalException {
180: com.liferay.portal.model.User returnValue = UserServiceUtil
181: .getUserByEmailAddress(companyId, emailAddress);
182:
183: return UserJSONSerializer.toJSONObject(returnValue);
184: }
185:
186: public static JSONObject getUserById(long userId)
187: throws java.rmi.RemoteException,
188: com.liferay.portal.SystemException,
189: com.liferay.portal.PortalException {
190: com.liferay.portal.model.User returnValue = UserServiceUtil
191: .getUserById(userId);
192:
193: return UserJSONSerializer.toJSONObject(returnValue);
194: }
195:
196: public static JSONObject getUserByScreenName(long companyId,
197: java.lang.String screenName)
198: throws java.rmi.RemoteException,
199: com.liferay.portal.SystemException,
200: com.liferay.portal.PortalException {
201: com.liferay.portal.model.User returnValue = UserServiceUtil
202: .getUserByScreenName(companyId, screenName);
203:
204: return UserJSONSerializer.toJSONObject(returnValue);
205: }
206:
207: public static long getUserIdByEmailAddress(long companyId,
208: java.lang.String emailAddress)
209: throws java.rmi.RemoteException,
210: com.liferay.portal.SystemException,
211: com.liferay.portal.PortalException {
212: long returnValue = UserServiceUtil.getUserIdByEmailAddress(
213: companyId, emailAddress);
214:
215: return returnValue;
216: }
217:
218: public static long getUserIdByScreenName(long companyId,
219: java.lang.String screenName)
220: throws java.rmi.RemoteException,
221: com.liferay.portal.SystemException,
222: com.liferay.portal.PortalException {
223: long returnValue = UserServiceUtil.getUserIdByScreenName(
224: companyId, screenName);
225:
226: return returnValue;
227: }
228:
229: public static boolean hasGroupUser(long groupId, long userId)
230: throws java.rmi.RemoteException,
231: com.liferay.portal.SystemException,
232: com.liferay.portal.PortalException {
233: boolean returnValue = UserServiceUtil.hasGroupUser(groupId,
234: userId);
235:
236: return returnValue;
237: }
238:
239: public static boolean hasRoleUser(long roleId, long userId)
240: throws java.rmi.RemoteException,
241: com.liferay.portal.SystemException,
242: com.liferay.portal.PortalException {
243: boolean returnValue = UserServiceUtil.hasRoleUser(roleId,
244: userId);
245:
246: return returnValue;
247: }
248:
249: public static void setRoleUsers(long roleId, long[] userIds)
250: throws java.rmi.RemoteException,
251: com.liferay.portal.SystemException,
252: com.liferay.portal.PortalException {
253: UserServiceUtil.setRoleUsers(roleId, userIds);
254: }
255:
256: public static void setUserGroupUsers(long userGroupId,
257: long[] userIds) throws java.rmi.RemoteException,
258: com.liferay.portal.SystemException,
259: com.liferay.portal.PortalException {
260: UserServiceUtil.setUserGroupUsers(userGroupId, userIds);
261: }
262:
263: public static void unsetGroupUsers(long groupId, long[] userIds)
264: throws java.rmi.RemoteException,
265: com.liferay.portal.SystemException,
266: com.liferay.portal.PortalException {
267: UserServiceUtil.unsetGroupUsers(groupId, userIds);
268: }
269:
270: public static void unsetOrganizationUsers(long organizationId,
271: long[] userIds) throws java.rmi.RemoteException,
272: com.liferay.portal.SystemException,
273: com.liferay.portal.PortalException {
274: UserServiceUtil.unsetOrganizationUsers(organizationId, userIds);
275: }
276:
277: public static void unsetPasswordPolicyUsers(long passwordPolicyId,
278: long[] userIds) throws java.rmi.RemoteException,
279: com.liferay.portal.SystemException,
280: com.liferay.portal.PortalException {
281: UserServiceUtil.unsetPasswordPolicyUsers(passwordPolicyId,
282: userIds);
283: }
284:
285: public static void unsetRoleUsers(long roleId, long[] userIds)
286: throws java.rmi.RemoteException,
287: com.liferay.portal.SystemException,
288: com.liferay.portal.PortalException {
289: UserServiceUtil.unsetRoleUsers(roleId, userIds);
290: }
291:
292: public static void unsetUserGroupUsers(long userGroupId,
293: long[] userIds) throws java.rmi.RemoteException,
294: com.liferay.portal.SystemException,
295: com.liferay.portal.PortalException {
296: UserServiceUtil.unsetUserGroupUsers(userGroupId, userIds);
297: }
298:
299: public static JSONObject updateActive(long userId, boolean active)
300: throws java.rmi.RemoteException,
301: com.liferay.portal.SystemException,
302: com.liferay.portal.PortalException {
303: com.liferay.portal.model.User returnValue = UserServiceUtil
304: .updateActive(userId, active);
305:
306: return UserJSONSerializer.toJSONObject(returnValue);
307: }
308:
309: public static JSONObject updateAgreedToTermsOfUse(long userId,
310: boolean agreedToTermsOfUse)
311: throws java.rmi.RemoteException,
312: com.liferay.portal.SystemException,
313: com.liferay.portal.PortalException {
314: com.liferay.portal.model.User returnValue = UserServiceUtil
315: .updateAgreedToTermsOfUse(userId, agreedToTermsOfUse);
316:
317: return UserJSONSerializer.toJSONObject(returnValue);
318: }
319:
320: public static JSONObject updateLockout(long userId, boolean lockout)
321: throws java.rmi.RemoteException,
322: com.liferay.portal.SystemException,
323: com.liferay.portal.PortalException {
324: com.liferay.portal.model.User returnValue = UserServiceUtil
325: .updateLockout(userId, lockout);
326:
327: return UserJSONSerializer.toJSONObject(returnValue);
328: }
329:
330: public static void updateOrganizations(long userId,
331: long[] organizationIds) throws java.rmi.RemoteException,
332: com.liferay.portal.SystemException,
333: com.liferay.portal.PortalException {
334: UserServiceUtil.updateOrganizations(userId, organizationIds);
335: }
336:
337: public static JSONObject updatePassword(long userId,
338: java.lang.String password1, java.lang.String password2,
339: boolean passwordReset) throws java.rmi.RemoteException,
340: com.liferay.portal.SystemException,
341: com.liferay.portal.PortalException {
342: com.liferay.portal.model.User returnValue = UserServiceUtil
343: .updatePassword(userId, password1, password2,
344: passwordReset);
345:
346: return UserJSONSerializer.toJSONObject(returnValue);
347: }
348:
349: public static void updatePortrait(long userId, byte[] bytes)
350: throws java.rmi.RemoteException,
351: com.liferay.portal.SystemException,
352: com.liferay.portal.PortalException {
353: UserServiceUtil.updatePortrait(userId, bytes);
354: }
355:
356: public static JSONObject updateUser(long userId,
357: java.lang.String oldPassword, boolean passwordReset,
358: java.lang.String screenName, java.lang.String emailAddress,
359: java.lang.String languageId, java.lang.String timeZoneId,
360: java.lang.String greeting, java.lang.String comments,
361: java.lang.String firstName, java.lang.String middleName,
362: java.lang.String lastName, int prefixId, int suffixId,
363: boolean male, int birthdayMonth, int birthdayDay,
364: int birthdayYear, java.lang.String smsSn,
365: java.lang.String aimSn, java.lang.String icqSn,
366: java.lang.String jabberSn, java.lang.String msnSn,
367: java.lang.String skypeSn, java.lang.String ymSn,
368: java.lang.String jobTitle, long[] organizationIds)
369: throws java.rmi.RemoteException,
370: com.liferay.portal.SystemException,
371: com.liferay.portal.PortalException {
372: com.liferay.portal.model.User returnValue = UserServiceUtil
373: .updateUser(userId, oldPassword, passwordReset,
374: screenName, emailAddress, languageId,
375: timeZoneId, greeting, comments, firstName,
376: middleName, lastName, prefixId, suffixId, male,
377: birthdayMonth, birthdayDay, birthdayYear,
378: smsSn, aimSn, icqSn, jabberSn, msnSn, skypeSn,
379: ymSn, jobTitle, organizationIds);
380:
381: return UserJSONSerializer.toJSONObject(returnValue);
382: }
383:
384: public static JSONObject updateUser(long userId,
385: java.lang.String oldPassword,
386: java.lang.String newPassword1,
387: java.lang.String newPassword2, boolean passwordReset,
388: java.lang.String screenName, java.lang.String emailAddress,
389: java.lang.String languageId, java.lang.String timeZoneId,
390: java.lang.String greeting, java.lang.String comments,
391: java.lang.String firstName, java.lang.String middleName,
392: java.lang.String lastName, int prefixId, int suffixId,
393: boolean male, int birthdayMonth, int birthdayDay,
394: int birthdayYear, java.lang.String smsSn,
395: java.lang.String aimSn, java.lang.String icqSn,
396: java.lang.String jabberSn, java.lang.String msnSn,
397: java.lang.String skypeSn, java.lang.String ymSn,
398: java.lang.String jobTitle, long[] organizationIds)
399: throws java.rmi.RemoteException,
400: com.liferay.portal.SystemException,
401: com.liferay.portal.PortalException {
402: com.liferay.portal.model.User returnValue = UserServiceUtil
403: .updateUser(userId, oldPassword, newPassword1,
404: newPassword2, passwordReset, screenName,
405: emailAddress, languageId, timeZoneId, greeting,
406: comments, firstName, middleName, lastName,
407: prefixId, suffixId, male, birthdayMonth,
408: birthdayDay, birthdayYear, smsSn, aimSn, icqSn,
409: jabberSn, msnSn, skypeSn, ymSn, jobTitle,
410: organizationIds);
411:
412: return UserJSONSerializer.toJSONObject(returnValue);
413: }
414: }
|