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,
77          java.util.List<com.liferay.portal.kernel.util.ObjectValuePair<String, byte[]>> files,
78          boolean anonymous, double priority, java.lang.String[] tagsEntries,
79          boolean addCommunityPermissions, boolean addGuestPermissions)
80          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
81              com.liferay.portal.PortalException {
82          com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
83                  subject, body, files, anonymous, priority, tagsEntries,
84                  addCommunityPermissions, addGuestPermissions);
85  
86          return MBMessageJSONSerializer.toJSONObject(returnValue);
87      }
88  
89      public static JSONObject addMessage(long categoryId,
90          java.lang.String subject, java.lang.String body,
91          java.util.List<com.liferay.portal.kernel.util.ObjectValuePair<String, byte[]>> files,
92          boolean anonymous, double priority, java.lang.String[] tagsEntries,
93          java.lang.String[] communityPermissions,
94          java.lang.String[] guestPermissions)
95          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
96              com.liferay.portal.PortalException {
97          com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
98                  subject, body, files, anonymous, priority, tagsEntries,
99                  communityPermissions, guestPermissions);
100 
101         return MBMessageJSONSerializer.toJSONObject(returnValue);
102     }
103 
104     public static JSONObject addMessage(long categoryId, long threadId,
105         long parentMessageId, java.lang.String subject, java.lang.String body,
106         java.util.List<com.liferay.portal.kernel.util.ObjectValuePair<String, byte[]>> files,
107         boolean anonymous, double priority, java.lang.String[] tagsEntries,
108         boolean addCommunityPermissions, boolean addGuestPermissions)
109         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
110             com.liferay.portal.PortalException {
111         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
112                 threadId, parentMessageId, subject, body, files, anonymous,
113                 priority, tagsEntries, addCommunityPermissions,
114                 addGuestPermissions);
115 
116         return MBMessageJSONSerializer.toJSONObject(returnValue);
117     }
118 
119     public static JSONObject addMessage(long categoryId, long threadId,
120         long parentMessageId, java.lang.String subject, java.lang.String body,
121         java.util.List<com.liferay.portal.kernel.util.ObjectValuePair<String, byte[]>> files,
122         boolean anonymous, double priority, java.lang.String[] tagsEntries,
123         java.lang.String[] communityPermissions,
124         java.lang.String[] guestPermissions)
125         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
126             com.liferay.portal.PortalException {
127         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.addMessage(categoryId,
128                 threadId, parentMessageId, subject, body, files, anonymous,
129                 priority, tagsEntries, communityPermissions, guestPermissions);
130 
131         return MBMessageJSONSerializer.toJSONObject(returnValue);
132     }
133 
134     public static void deleteDiscussionMessage(long groupId,
135         java.lang.String className, long classPK, long messageId)
136         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
137             com.liferay.portal.PortalException {
138         MBMessageServiceUtil.deleteDiscussionMessage(groupId, className,
139             classPK, messageId);
140     }
141 
142     public static void deleteMessage(long messageId)
143         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
144             com.liferay.portal.PortalException {
145         MBMessageServiceUtil.deleteMessage(messageId);
146     }
147 
148     public static JSONArray getCategoryMessages(long categoryId, int begin,
149         int end)
150         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
151             com.liferay.portal.PortalException {
152         java.util.List<com.liferay.portlet.messageboards.model.MBMessage> returnValue =
153             MBMessageServiceUtil.getCategoryMessages(categoryId, begin, end);
154 
155         return MBMessageJSONSerializer.toJSONArray(returnValue);
156     }
157 
158     public static int getCategoryMessagesCount(long categoryId)
159         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
160             com.liferay.portal.PortalException {
161         int returnValue = MBMessageServiceUtil.getCategoryMessagesCount(categoryId);
162 
163         return returnValue;
164     }
165 
166     public static java.lang.String getCategoryMessagesRSS(long categoryId,
167         int max, java.lang.String type, double version,
168         java.lang.String displayStyle, java.lang.String feedURL,
169         java.lang.String entryURL)
170         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
171             com.liferay.portal.PortalException {
172         java.lang.String returnValue = MBMessageServiceUtil.getCategoryMessagesRSS(categoryId,
173                 max, type, version, displayStyle, feedURL, entryURL);
174 
175         return returnValue;
176     }
177 
178     public static java.lang.String getCompanyMessagesRSS(long companyId,
179         int max, java.lang.String type, double version,
180         java.lang.String displayStyle, java.lang.String feedURL,
181         java.lang.String entryURL)
182         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
183             com.liferay.portal.PortalException {
184         java.lang.String returnValue = MBMessageServiceUtil.getCompanyMessagesRSS(companyId,
185                 max, type, version, displayStyle, feedURL, entryURL);
186 
187         return returnValue;
188     }
189 
190     public static java.lang.String getGroupMessagesRSS(long groupId, int max,
191         java.lang.String type, double version, java.lang.String displayStyle,
192         java.lang.String feedURL, java.lang.String entryURL)
193         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
194             com.liferay.portal.PortalException {
195         java.lang.String returnValue = MBMessageServiceUtil.getGroupMessagesRSS(groupId,
196                 max, type, version, displayStyle, feedURL, entryURL);
197 
198         return returnValue;
199     }
200 
201     public static java.lang.String getGroupMessagesRSS(long groupId,
202         long userId, int max, java.lang.String type, double version,
203         java.lang.String displayStyle, java.lang.String feedURL,
204         java.lang.String entryURL)
205         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
206             com.liferay.portal.PortalException {
207         java.lang.String returnValue = MBMessageServiceUtil.getGroupMessagesRSS(groupId,
208                 userId, max, type, version, displayStyle, feedURL, entryURL);
209 
210         return returnValue;
211     }
212 
213     public static JSONObject getMessage(long messageId)
214         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
215             com.liferay.portal.PortalException {
216         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.getMessage(messageId);
217 
218         return MBMessageJSONSerializer.toJSONObject(returnValue);
219     }
220 
221     public static com.liferay.portlet.messageboards.model.MBMessageDisplay getMessageDisplay(
222         long messageId)
223         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
224             com.liferay.portal.PortalException {
225         com.liferay.portlet.messageboards.model.MBMessageDisplay returnValue = MBMessageServiceUtil.getMessageDisplay(messageId);
226 
227         return returnValue;
228     }
229 
230     public static java.lang.String getThreadMessagesRSS(long threadId, int max,
231         java.lang.String type, double version, java.lang.String displayStyle,
232         java.lang.String feedURL, java.lang.String entryURL)
233         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
234             com.liferay.portal.PortalException {
235         java.lang.String returnValue = MBMessageServiceUtil.getThreadMessagesRSS(threadId,
236                 max, type, version, displayStyle, feedURL, entryURL);
237 
238         return returnValue;
239     }
240 
241     public static void subscribeMessage(long messageId)
242         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
243             com.liferay.portal.PortalException {
244         MBMessageServiceUtil.subscribeMessage(messageId);
245     }
246 
247     public static void unsubscribeMessage(long messageId)
248         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
249             com.liferay.portal.PortalException {
250         MBMessageServiceUtil.unsubscribeMessage(messageId);
251     }
252 
253     public static JSONObject updateDiscussionMessage(long groupId,
254         java.lang.String className, long classPK, long messageId,
255         java.lang.String subject, java.lang.String body)
256         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
257             com.liferay.portal.PortalException {
258         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.updateDiscussionMessage(groupId,
259                 className, classPK, messageId, subject, body);
260 
261         return MBMessageJSONSerializer.toJSONObject(returnValue);
262     }
263 
264     public static JSONObject updateMessage(long messageId,
265         java.lang.String subject, java.lang.String body,
266         java.util.List<com.liferay.portal.kernel.util.ObjectValuePair<String, byte[]>> files,
267         java.util.List<String> existingFiles, double priority,
268         java.lang.String[] tagsEntries)
269         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
270             com.liferay.portal.PortalException {
271         com.liferay.portlet.messageboards.model.MBMessage returnValue = MBMessageServiceUtil.updateMessage(messageId,
272                 subject, body, files, existingFiles, priority, tagsEntries);
273 
274         return MBMessageJSONSerializer.toJSONObject(returnValue);
275     }
276 }