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.portlet.messageboards.service.http;
24  
25  import com.liferay.portlet.messageboards.service.MBMessageServiceUtil;
26  
27  import org.json.JSONArray;
28  import org.json.JSONObject;
29  
30  /**
31   * <a href="MBMessageServiceJSON.java.html"><b><i>View Source</i></b></a>
32   *
33   * <p>
34   * ServiceBuilder generated this class. Modifications in this class will be
35   * overwritten the next time is generated.
36   * </p>
37   *
38   * <p>
39   * This class provides a JSON utility for the
40   * <code>com.liferay.portlet.messageboards.service.MBMessageServiceUtil</code>
41   * service utility. The static methods of this class calls the same methods of
42   * the service utility. However, the signatures are different because it is
43   * difficult for JSON to support certain types.
44   * </p>
45   *
46   * <p>
47   * ServiceBuilder follows certain rules in translating the methods. For example,
48   * if the method in the service utility returns a <code>java.util.List</code>,
49   * that is translated to a <code>org.json.JSONArray</code>. If the method in the
50   * service utility returns a <code>com.liferay.portlet.messageboards.model.MBMessage</code>,
51   * that is translated to a <code>org.json.JSONObject</code>. Methods that JSON
52   * cannot safely use are skipped. The logic for the translation is encapsulated
53   * in <code>com.liferay.portlet.messageboards.service.http.MBMessageJSONSerializer</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.portlet.messageboards.service.MBMessageServiceUtil
71   * @see com.liferay.portlet.messageboards.service.http.MBMessageJSONSerializer
72   *
73   */
74  public class MBMessageServiceJSON {
75      public static JSONObject addMessage(long categoryId,
76          java.lang.String subject, java.lang.String body, java.util.List files,
77          boolean anonymous, double priority, java.lang.String[] tagsEntries,
78          boolean addCommunityPermissions, boolean addGuestPermissions)
79          throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
80              com.liferay.portal.PortalException {
81          com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
82                  subject, body, files, anonymous, priority, tagsEntries,
83                  addCommunityPermissions, addGuestPermissions);
84  
85          return MBMessageJSONSerializer.toJSONObject(returnValue);
86      }
87  
88      public static JSONObject addMessage(long categoryId,
89          java.lang.String subject, java.lang.String body, java.util.List files,
90          boolean anonymous, double priority, java.lang.String[] tagsEntries,
91          java.lang.String[] communityPermissions,
92          java.lang.String[] guestPermissions)
93          throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
94              com.liferay.portal.PortalException {
95          com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
96                  subject, body, files, anonymous, priority, tagsEntries,
97                  communityPermissions, guestPermissions);
98  
99          return MBMessageJSONSerializer.toJSONObject(returnValue);
100     }
101 
102     public static JSONObject addMessage(long categoryId, long threadId,
103         long parentMessageId, java.lang.String subject, java.lang.String body,
104         java.util.List files, boolean anonymous, double priority,
105         java.lang.String[] tagsEntries, boolean addCommunityPermissions,
106         boolean addGuestPermissions)
107         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
108             com.liferay.portal.PortalException {
109         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
110                 threadId, parentMessageId, subject, body, files, anonymous,
111                 priority, tagsEntries, addCommunityPermissions,
112                 addGuestPermissions);
113 
114         return MBMessageJSONSerializer.toJSONObject(returnValue);
115     }
116 
117     public static JSONObject addMessage(long categoryId, long threadId,
118         long parentMessageId, java.lang.String subject, java.lang.String body,
119         java.util.List files, boolean anonymous, double priority,
120         java.lang.String[] tagsEntries,
121         java.lang.String[] communityPermissions,
122         java.lang.String[] guestPermissions)
123         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
124             com.liferay.portal.PortalException {
125         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
126                 threadId, parentMessageId, subject, body, files, anonymous,
127                 priority, tagsEntries, communityPermissions, guestPermissions);
128 
129         return MBMessageJSONSerializer.toJSONObject(returnValue);
130     }
131 
132     public static void deleteDiscussionMessage(long groupId,
133         java.lang.String className, long classPK, long messageId)
134         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
135             com.liferay.portal.PortalException {
136         MBMessageServiceUtil.deleteDiscussionMessage(groupId, className,
137             classPK, messageId);
138     }
139 
140     public static void deleteMessage(long messageId)
141         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
142             com.liferay.portal.PortalException {
143         MBMessageServiceUtil.deleteMessage(messageId);
144     }
145 
146     public static JSONArray getCategoryMessages(long categoryId, int begin,
147         int end)
148         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
149             com.liferay.portal.PortalException {
150         java.util.List returnValue = MBMessageServiceUtil.getCategoryMessages(categoryId,
151                 begin, end);
152 
153         return MBMessageJSONSerializer.toJSONArray(returnValue);
154     }
155 
156     public static int getCategoryMessagesCount(long categoryId)
157         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
158             com.liferay.portal.PortalException {
159         int returnValue = MBMessageServiceUtil.getCategoryMessagesCount(categoryId);
160 
161         return returnValue;
162     }
163 
164     public static java.lang.String getCategoryMessagesRSS(long categoryId,
165         int max, java.lang.String type, double version,
166         java.lang.String displayStyle, java.lang.String feedURL,
167         java.lang.String entryURL)
168         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
169             com.liferay.portal.PortalException {
170         java.lang.String returnValue = MBMessageServiceUtil.getCategoryMessagesRSS(categoryId,
171                 max, type, version, displayStyle, feedURL, entryURL);
172 
173         return returnValue;
174     }
175 
176     public static java.lang.String getCompanyMessagesRSS(long companyId,
177         int max, java.lang.String type, double version,
178         java.lang.String displayStyle, java.lang.String feedURL,
179         java.lang.String entryURL)
180         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
181             com.liferay.portal.PortalException {
182         java.lang.String returnValue = MBMessageServiceUtil.getCompanyMessagesRSS(companyId,
183                 max, type, version, displayStyle, feedURL, entryURL);
184 
185         return returnValue;
186     }
187 
188     public static java.lang.String getGroupMessagesRSS(long groupId, int max,
189         java.lang.String type, double version, java.lang.String displayStyle,
190         java.lang.String feedURL, java.lang.String entryURL)
191         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
192             com.liferay.portal.PortalException {
193         java.lang.String returnValue = MBMessageServiceUtil.getGroupMessagesRSS(groupId,
194                 max, type, version, displayStyle, feedURL, entryURL);
195 
196         return returnValue;
197     }
198 
199     public static java.lang.String getGroupMessagesRSS(long groupId,
200         long userId, int max, java.lang.String type, double version,
201         java.lang.String displayStyle, java.lang.String feedURL,
202         java.lang.String entryURL)
203         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
204             com.liferay.portal.PortalException {
205         java.lang.String returnValue = MBMessageServiceUtil.getGroupMessagesRSS(groupId,
206                 userId, max, type, version, displayStyle, feedURL, entryURL);
207 
208         return returnValue;
209     }
210 
211     public static JSONObject getMessage(long messageId)
212         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
213             com.liferay.portal.PortalException {
214         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.getMessage(messageId);
215 
216         return MBMessageJSONSerializer.toJSONObject(returnValue);
217     }
218 
219     public static com.liferay.portlet.messageboards.model.MBMessageDisplay getMessageDisplay(
220         long messageId)
221         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
222             com.liferay.portal.PortalException {
223         com.liferay.portlet.messageboards.model.MBMessageDisplay returnValue = MBMessageServiceUtil.getMessageDisplay(messageId);
224 
225         return returnValue;
226     }
227 
228     public static java.lang.String getThreadMessagesRSS(long threadId, int max,
229         java.lang.String type, double version, java.lang.String displayStyle,
230         java.lang.String feedURL, java.lang.String entryURL)
231         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
232             com.liferay.portal.PortalException {
233         java.lang.String returnValue = MBMessageServiceUtil.getThreadMessagesRSS(threadId,
234                 max, type, version, displayStyle, feedURL, entryURL);
235 
236         return returnValue;
237     }
238 
239     public static void subscribeMessage(long messageId)
240         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
241             com.liferay.portal.PortalException {
242         MBMessageServiceUtil.subscribeMessage(messageId);
243     }
244 
245     public static void unsubscribeMessage(long messageId)
246         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
247             com.liferay.portal.PortalException {
248         MBMessageServiceUtil.unsubscribeMessage(messageId);
249     }
250 
251     public static JSONObject updateDiscussionMessage(long groupId,
252         java.lang.String className, long classPK, long messageId,
253         java.lang.String subject, java.lang.String body)
254         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
255             com.liferay.portal.PortalException {
256         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.updateDiscussionMessage(groupId,
257                 className, classPK, messageId, subject, body);
258 
259         return MBMessageJSONSerializer.toJSONObject(returnValue);
260     }
261 
262     public static JSONObject updateMessage(long messageId,
263         java.lang.String subject, java.lang.String body, java.util.List files,
264         double priority, java.lang.String[] tagsEntries)
265         throws java.rmi.RemoteException, com.liferay.portal.SystemException, 
266             com.liferay.portal.PortalException {
267         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.updateMessage(messageId,
268                 subject, body, files, priority, tagsEntries);
269 
270         return MBMessageJSONSerializer.toJSONObject(returnValue);
271     }
272 }