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.GroupServiceUtil;
024:
025: import org.json.JSONArray;
026: import org.json.JSONObject;
027:
028: /**
029: * <a href="GroupServiceJSON.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.GroupServiceUtil</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.Group</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.GroupJSONSerializer</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.GroupServiceUtil
069: * @see com.liferay.portal.service.http.GroupJSONSerializer
070: *
071: */
072: public class GroupServiceJSON {
073: public static JSONObject addGroup(java.lang.String name,
074: java.lang.String description, int type,
075: java.lang.String friendlyURL, boolean active)
076: throws java.rmi.RemoteException,
077: com.liferay.portal.SystemException,
078: com.liferay.portal.PortalException {
079: com.liferay.portal.model.Group returnValue = GroupServiceUtil
080: .addGroup(name, description, type, friendlyURL, active);
081:
082: return GroupJSONSerializer.toJSONObject(returnValue);
083: }
084:
085: public static JSONObject addGroup(long liveGroupId,
086: java.lang.String name, java.lang.String description,
087: int type, java.lang.String friendlyURL, boolean active)
088: throws java.rmi.RemoteException,
089: com.liferay.portal.SystemException,
090: com.liferay.portal.PortalException {
091: com.liferay.portal.model.Group returnValue = GroupServiceUtil
092: .addGroup(liveGroupId, name, description, type,
093: friendlyURL, active);
094:
095: return GroupJSONSerializer.toJSONObject(returnValue);
096: }
097:
098: public static void addRoleGroups(long roleId, long[] groupIds)
099: throws java.rmi.RemoteException,
100: com.liferay.portal.SystemException,
101: com.liferay.portal.PortalException {
102: GroupServiceUtil.addRoleGroups(roleId, groupIds);
103: }
104:
105: public static void deleteGroup(long groupId)
106: throws java.rmi.RemoteException,
107: com.liferay.portal.SystemException,
108: com.liferay.portal.PortalException {
109: GroupServiceUtil.deleteGroup(groupId);
110: }
111:
112: public static JSONObject getGroup(long groupId)
113: throws java.rmi.RemoteException,
114: com.liferay.portal.SystemException,
115: com.liferay.portal.PortalException {
116: com.liferay.portal.model.Group returnValue = GroupServiceUtil
117: .getGroup(groupId);
118:
119: return GroupJSONSerializer.toJSONObject(returnValue);
120: }
121:
122: public static JSONObject getGroup(long companyId,
123: java.lang.String name) throws java.rmi.RemoteException,
124: com.liferay.portal.SystemException,
125: com.liferay.portal.PortalException {
126: com.liferay.portal.model.Group returnValue = GroupServiceUtil
127: .getGroup(companyId, name);
128:
129: return GroupJSONSerializer.toJSONObject(returnValue);
130: }
131:
132: public static JSONArray getOrganizationsGroups(
133: java.util.List organizations)
134: throws java.rmi.RemoteException,
135: com.liferay.portal.SystemException,
136: com.liferay.portal.PortalException {
137: java.util.List returnValue = GroupServiceUtil
138: .getOrganizationsGroups(organizations);
139:
140: return GroupJSONSerializer.toJSONArray(returnValue);
141: }
142:
143: public static JSONArray getUserGroupsGroups(
144: java.util.List userGroups) throws java.rmi.RemoteException,
145: com.liferay.portal.SystemException,
146: com.liferay.portal.PortalException {
147: java.util.List returnValue = GroupServiceUtil
148: .getUserGroupsGroups(userGroups);
149:
150: return GroupJSONSerializer.toJSONArray(returnValue);
151: }
152:
153: public static boolean hasUserGroup(long userId, long groupId)
154: throws java.rmi.RemoteException,
155: com.liferay.portal.SystemException {
156: boolean returnValue = GroupServiceUtil.hasUserGroup(userId,
157: groupId);
158:
159: return returnValue;
160: }
161:
162: public static JSONArray search(long companyId,
163: java.lang.String name, java.lang.String description,
164: java.lang.String[] params, int begin, int end)
165: throws java.rmi.RemoteException,
166: com.liferay.portal.SystemException {
167: java.util.List returnValue = GroupServiceUtil.search(companyId,
168: name, description, params, begin, end);
169:
170: return GroupJSONSerializer.toJSONArray(returnValue);
171: }
172:
173: public static int searchCount(long companyId,
174: java.lang.String name, java.lang.String description,
175: java.lang.String[] params) throws java.rmi.RemoteException,
176: com.liferay.portal.SystemException {
177: int returnValue = GroupServiceUtil.searchCount(companyId, name,
178: description, params);
179:
180: return returnValue;
181: }
182:
183: public static void setRoleGroups(long roleId, long[] groupIds)
184: throws java.rmi.RemoteException,
185: com.liferay.portal.SystemException,
186: com.liferay.portal.PortalException {
187: GroupServiceUtil.setRoleGroups(roleId, groupIds);
188: }
189:
190: public static void unsetRoleGroups(long roleId, long[] groupIds)
191: throws java.rmi.RemoteException,
192: com.liferay.portal.SystemException,
193: com.liferay.portal.PortalException {
194: GroupServiceUtil.unsetRoleGroups(roleId, groupIds);
195: }
196:
197: public static JSONObject updateGroup(long groupId,
198: java.lang.String name, java.lang.String description,
199: int type, java.lang.String friendlyURL, boolean active)
200: throws java.rmi.RemoteException,
201: com.liferay.portal.SystemException,
202: com.liferay.portal.PortalException {
203: com.liferay.portal.model.Group returnValue = GroupServiceUtil
204: .updateGroup(groupId, name, description, type,
205: friendlyURL, active);
206:
207: return GroupJSONSerializer.toJSONObject(returnValue);
208: }
209:
210: public static JSONObject updateGroup(long groupId,
211: java.lang.String typeSettings)
212: throws java.rmi.RemoteException,
213: com.liferay.portal.SystemException,
214: com.liferay.portal.PortalException {
215: com.liferay.portal.model.Group returnValue = GroupServiceUtil
216: .updateGroup(groupId, typeSettings);
217:
218: return GroupJSONSerializer.toJSONObject(returnValue);
219: }
220: }
|