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.portlet.messageboards.service.http;
022:
023: import com.liferay.portlet.messageboards.service.MBMessageServiceUtil;
024:
025: import org.json.JSONArray;
026: import org.json.JSONObject;
027:
028: /**
029: * <a href="MBMessageServiceJSON.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.portlet.messageboards.service.MBMessageServiceUtil</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.portlet.messageboards.model.MBMessage</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.portlet.messageboards.service.http.MBMessageJSONSerializer</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.portlet.messageboards.service.MBMessageServiceUtil
069: * @see com.liferay.portlet.messageboards.service.http.MBMessageJSONSerializer
070: *
071: */
072: public class MBMessageServiceJSON {
073: public static JSONObject addMessage(long categoryId,
074: java.lang.String subject, java.lang.String body,
075: java.util.List files, boolean anonymous, double priority,
076: java.lang.String[] tagsEntries,
077: boolean addCommunityPermissions, boolean addGuestPermissions)
078: throws java.rmi.RemoteException,
079: com.liferay.portal.SystemException,
080: com.liferay.portal.PortalException {
081: com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil
082: .addMessage(categoryId, subject, body, files,
083: anonymous, priority, tagsEntries,
084: addCommunityPermissions, addGuestPermissions);
085:
086: return MBMessageJSONSerializer.toJSONObject(returnValue);
087: }
088:
089: public static JSONObject addMessage(long categoryId,
090: java.lang.String subject, java.lang.String body,
091: java.util.List files, boolean anonymous, double priority,
092: java.lang.String[] tagsEntries,
093: java.lang.String[] communityPermissions,
094: java.lang.String[] guestPermissions)
095: throws java.rmi.RemoteException,
096: com.liferay.portal.SystemException,
097: com.liferay.portal.PortalException {
098: com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil
099: .addMessage(categoryId, subject, body, files,
100: anonymous, priority, tagsEntries,
101: communityPermissions, guestPermissions);
102:
103: return MBMessageJSONSerializer.toJSONObject(returnValue);
104: }
105:
106: public static JSONObject addMessage(long categoryId, long threadId,
107: long parentMessageId, java.lang.String subject,
108: java.lang.String body, java.util.List files,
109: boolean anonymous, double priority,
110: java.lang.String[] tagsEntries,
111: boolean addCommunityPermissions, boolean addGuestPermissions)
112: throws java.rmi.RemoteException,
113: com.liferay.portal.SystemException,
114: com.liferay.portal.PortalException {
115: com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil
116: .addMessage(categoryId, threadId, parentMessageId,
117: subject, body, files, anonymous, priority,
118: tagsEntries, addCommunityPermissions,
119: addGuestPermissions);
120:
121: return MBMessageJSONSerializer.toJSONObject(returnValue);
122: }
123:
124: public static JSONObject addMessage(long categoryId, long threadId,
125: long parentMessageId, java.lang.String subject,
126: java.lang.String body, java.util.List files,
127: boolean anonymous, double priority,
128: java.lang.String[] tagsEntries,
129: java.lang.String[] communityPermissions,
130: java.lang.String[] guestPermissions)
131: throws java.rmi.RemoteException,
132: com.liferay.portal.SystemException,
133: com.liferay.portal.PortalException {
134: com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil
135: .addMessage(categoryId, threadId, parentMessageId,
136: subject, body, files, anonymous, priority,
137: tagsEntries, communityPermissions,
138: guestPermissions);
139:
140: return MBMessageJSONSerializer.toJSONObject(returnValue);
141: }
142:
143: public static void deleteDiscussionMessage(long groupId,
144: java.lang.String className, long classPK, long messageId)
145: throws java.rmi.RemoteException,
146: com.liferay.portal.SystemException,
147: com.liferay.portal.PortalException {
148: MBMessageServiceUtil.deleteDiscussionMessage(groupId,
149: className, classPK, messageId);
150: }
151:
152: public static void deleteMessage(long messageId)
153: throws java.rmi.RemoteException,
154: com.liferay.portal.SystemException,
155: com.liferay.portal.PortalException {
156: MBMessageServiceUtil.deleteMessage(messageId);
157: }
158:
159: public static JSONArray getCategoryMessages(long categoryId,
160: int begin, int end) throws java.rmi.RemoteException,
161: com.liferay.portal.SystemException,
162: com.liferay.portal.PortalException {
163: java.util.List returnValue = MBMessageServiceUtil
164: .getCategoryMessages(categoryId, begin, end);
165:
166: return MBMessageJSONSerializer.toJSONArray(returnValue);
167: }
168:
169: public static int getCategoryMessagesCount(long categoryId)
170: throws java.rmi.RemoteException,
171: com.liferay.portal.SystemException,
172: com.liferay.portal.PortalException {
173: int returnValue = MBMessageServiceUtil
174: .getCategoryMessagesCount(categoryId);
175:
176: return returnValue;
177: }
178:
179: public static java.lang.String getCategoryMessagesRSS(
180: long categoryId, int max, java.lang.String type,
181: double version, java.lang.String displayStyle,
182: java.lang.String feedURL, java.lang.String entryURL)
183: throws java.rmi.RemoteException,
184: com.liferay.portal.SystemException,
185: com.liferay.portal.PortalException {
186: java.lang.String returnValue = MBMessageServiceUtil
187: .getCategoryMessagesRSS(categoryId, max, type, version,
188: displayStyle, feedURL, entryURL);
189:
190: return returnValue;
191: }
192:
193: public static java.lang.String getCompanyMessagesRSS(
194: long companyId, int max, java.lang.String type,
195: double version, java.lang.String displayStyle,
196: java.lang.String feedURL, java.lang.String entryURL)
197: throws java.rmi.RemoteException,
198: com.liferay.portal.SystemException,
199: com.liferay.portal.PortalException {
200: java.lang.String returnValue = MBMessageServiceUtil
201: .getCompanyMessagesRSS(companyId, max, type, version,
202: displayStyle, feedURL, entryURL);
203:
204: return returnValue;
205: }
206:
207: public static java.lang.String getGroupMessagesRSS(long groupId,
208: int max, java.lang.String type, double version,
209: java.lang.String displayStyle, java.lang.String feedURL,
210: java.lang.String entryURL) throws java.rmi.RemoteException,
211: com.liferay.portal.SystemException,
212: com.liferay.portal.PortalException {
213: java.lang.String returnValue = MBMessageServiceUtil
214: .getGroupMessagesRSS(groupId, max, type, version,
215: displayStyle, feedURL, entryURL);
216:
217: return returnValue;
218: }
219:
220: public static java.lang.String getGroupMessagesRSS(long groupId,
221: long userId, int max, java.lang.String type,
222: double version, java.lang.String displayStyle,
223: java.lang.String feedURL, java.lang.String entryURL)
224: throws java.rmi.RemoteException,
225: com.liferay.portal.SystemException,
226: com.liferay.portal.PortalException {
227: java.lang.String returnValue = MBMessageServiceUtil
228: .getGroupMessagesRSS(groupId, userId, max, type,
229: version, displayStyle, feedURL, entryURL);
230:
231: return returnValue;
232: }
233:
234: public static JSONObject getMessage(long messageId)
235: throws java.rmi.RemoteException,
236: com.liferay.portal.SystemException,
237: com.liferay.portal.PortalException {
238: com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil
239: .getMessage(messageId);
240:
241: return MBMessageJSONSerializer.toJSONObject(returnValue);
242: }
243:
244: public static com.liferay.portlet.messageboards.model.MBMessageDisplay getMessageDisplay(
245: long messageId) throws java.rmi.RemoteException,
246: com.liferay.portal.SystemException,
247: com.liferay.portal.PortalException {
248: com.liferay.portlet.messageboards.model.MBMessageDisplay returnValue = MBMessageServiceUtil
249: .getMessageDisplay(messageId);
250:
251: return returnValue;
252: }
253:
254: public static java.lang.String getThreadMessagesRSS(long threadId,
255: int max, java.lang.String type, double version,
256: java.lang.String displayStyle, java.lang.String feedURL,
257: java.lang.String entryURL) throws java.rmi.RemoteException,
258: com.liferay.portal.SystemException,
259: com.liferay.portal.PortalException {
260: java.lang.String returnValue = MBMessageServiceUtil
261: .getThreadMessagesRSS(threadId, max, type, version,
262: displayStyle, feedURL, entryURL);
263:
264: return returnValue;
265: }
266:
267: public static void subscribeMessage(long messageId)
268: throws java.rmi.RemoteException,
269: com.liferay.portal.SystemException,
270: com.liferay.portal.PortalException {
271: MBMessageServiceUtil.subscribeMessage(messageId);
272: }
273:
274: public static void unsubscribeMessage(long messageId)
275: throws java.rmi.RemoteException,
276: com.liferay.portal.SystemException,
277: com.liferay.portal.PortalException {
278: MBMessageServiceUtil.unsubscribeMessage(messageId);
279: }
280:
281: public static JSONObject updateDiscussionMessage(long groupId,
282: java.lang.String className, long classPK, long messageId,
283: java.lang.String subject, java.lang.String body)
284: throws java.rmi.RemoteException,
285: com.liferay.portal.SystemException,
286: com.liferay.portal.PortalException {
287: com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil
288: .updateDiscussionMessage(groupId, className, classPK,
289: messageId, subject, body);
290:
291: return MBMessageJSONSerializer.toJSONObject(returnValue);
292: }
293:
294: public static JSONObject updateMessage(long messageId,
295: java.lang.String subject, java.lang.String body,
296: java.util.List files, double priority,
297: java.lang.String[] tagsEntries)
298: throws java.rmi.RemoteException,
299: com.liferay.portal.SystemException,
300: com.liferay.portal.PortalException {
301: com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil
302: .updateMessage(messageId, subject, body, files,
303: priority, tagsEntries);
304:
305: return MBMessageJSONSerializer.toJSONObject(returnValue);
306: }
307: }
|