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.expando.service.http;
24  
25  import com.liferay.portlet.expando.service.ExpandoValueServiceUtil;
26  
27  import org.json.JSONArray;
28  import org.json.JSONObject;
29  
30  /**
31   * <a href="ExpandoValueServiceJSON.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.expando.service.ExpandoValueServiceUtil</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.expando.model.ExpandoValue</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.expando.service.http.ExpandoValueJSONSerializer</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.expando.service.ExpandoValueServiceUtil
71   * @see com.liferay.portlet.expando.service.http.ExpandoValueJSONSerializer
72   *
73   */
74  public class ExpandoValueServiceJSON {
75      public static JSONObject addValue(long columnId, long rowId, long classPK,
76          java.lang.String data)
77          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
78              com.liferay.portal.PortalException {
79          com.liferay.portlet.expando.model.ExpandoValue returnValue = ExpandoValueServiceUtil.addValue(columnId,
80                  rowId, classPK, data);
81  
82          return ExpandoValueJSONSerializer.toJSONObject(returnValue);
83      }
84  
85      public static void deleteColumnValues(long columnId)
86          throws java.rmi.RemoteException, com.liferay.portal.SystemException {
87          ExpandoValueServiceUtil.deleteColumnValues(columnId);
88      }
89  
90      public static void deleteRowValues(long rowId)
91          throws java.rmi.RemoteException, com.liferay.portal.SystemException {
92          ExpandoValueServiceUtil.deleteRowValues(rowId);
93      }
94  
95      public static void deleteTableValues(long tableId)
96          throws java.rmi.RemoteException, com.liferay.portal.SystemException {
97          ExpandoValueServiceUtil.deleteTableValues(tableId);
98      }
99  
100     public static void deleteValue(long valueId)
101         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
102             com.liferay.portal.PortalException {
103         ExpandoValueServiceUtil.deleteValue(valueId);
104     }
105 
106     public static void deleteValues(java.lang.String className, long classPK)
107         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
108             com.liferay.portal.PortalException {
109         ExpandoValueServiceUtil.deleteValues(className, classPK);
110     }
111 
112     public static void deleteValues(long classNameId, long classPK)
113         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
114             com.liferay.portal.PortalException {
115         ExpandoValueServiceUtil.deleteValues(classNameId, classPK);
116     }
117 
118     public static JSONArray getColumnValues(long columnId, int begin, int end)
119         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
120         java.util.List<com.liferay.portlet.expando.model.ExpandoValue> returnValue =
121             ExpandoValueServiceUtil.getColumnValues(columnId, begin, end);
122 
123         return ExpandoValueJSONSerializer.toJSONArray(returnValue);
124     }
125 
126     public static JSONArray getColumnValues(java.lang.String className,
127         java.lang.String tableName, java.lang.String columnName, int begin,
128         int end)
129         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
130         java.util.List<com.liferay.portlet.expando.model.ExpandoValue> returnValue =
131             ExpandoValueServiceUtil.getColumnValues(className, tableName,
132                 columnName, begin, end);
133 
134         return ExpandoValueJSONSerializer.toJSONArray(returnValue);
135     }
136 
137     public static JSONArray getColumnValues(long classNameId,
138         java.lang.String tableName, java.lang.String columnName, int begin,
139         int end)
140         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
141         java.util.List<com.liferay.portlet.expando.model.ExpandoValue> returnValue =
142             ExpandoValueServiceUtil.getColumnValues(classNameId, tableName,
143                 columnName, begin, end);
144 
145         return ExpandoValueJSONSerializer.toJSONArray(returnValue);
146     }
147 
148     public static int getColumnValuesCount(long columnId)
149         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
150         int returnValue = ExpandoValueServiceUtil.getColumnValuesCount(columnId);
151 
152         return returnValue;
153     }
154 
155     public static int getColumnValuesCount(java.lang.String className,
156         java.lang.String tableName, java.lang.String columnName)
157         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
158         int returnValue = ExpandoValueServiceUtil.getColumnValuesCount(className,
159                 tableName, columnName);
160 
161         return returnValue;
162     }
163 
164     public static int getColumnValuesCount(long classNameId,
165         java.lang.String tableName, java.lang.String columnName)
166         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
167         int returnValue = ExpandoValueServiceUtil.getColumnValuesCount(classNameId,
168                 tableName, columnName);
169 
170         return returnValue;
171     }
172 
173     public static JSONArray getDefaultTableColumnValues(
174         java.lang.String className, java.lang.String columnName, int begin,
175         int end)
176         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
177         java.util.List<com.liferay.portlet.expando.model.ExpandoValue> returnValue =
178             ExpandoValueServiceUtil.getDefaultTableColumnValues(className,
179                 columnName, begin, end);
180 
181         return ExpandoValueJSONSerializer.toJSONArray(returnValue);
182     }
183 
184     public static JSONArray getDefaultTableColumnValues(long classNameId,
185         java.lang.String columnName, int begin, int end)
186         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
187         java.util.List<com.liferay.portlet.expando.model.ExpandoValue> returnValue =
188             ExpandoValueServiceUtil.getDefaultTableColumnValues(classNameId,
189                 columnName, begin, end);
190 
191         return ExpandoValueJSONSerializer.toJSONArray(returnValue);
192     }
193 
194     public static int getDefaultTableColumnValuesCount(
195         java.lang.String className, java.lang.String columnName)
196         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
197         int returnValue = ExpandoValueServiceUtil.getDefaultTableColumnValuesCount(className,
198                 columnName);
199 
200         return returnValue;
201     }
202 
203     public static int getDefaultTableColumnValuesCount(long classNameId,
204         java.lang.String columnName)
205         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
206         int returnValue = ExpandoValueServiceUtil.getDefaultTableColumnValuesCount(classNameId,
207                 columnName);
208 
209         return returnValue;
210     }
211 
212     public static JSONArray getRowValues(long rowId)
213         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
214         java.util.List<com.liferay.portlet.expando.model.ExpandoValue> returnValue =
215             ExpandoValueServiceUtil.getRowValues(rowId);
216 
217         return ExpandoValueJSONSerializer.toJSONArray(returnValue);
218     }
219 
220     public static JSONArray getRowValues(long rowId, int begin, int end)
221         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
222         java.util.List<com.liferay.portlet.expando.model.ExpandoValue> returnValue =
223             ExpandoValueServiceUtil.getRowValues(rowId, begin, end);
224 
225         return ExpandoValueJSONSerializer.toJSONArray(returnValue);
226     }
227 
228     public static int getRowValuesCount(long rowId)
229         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
230         int returnValue = ExpandoValueServiceUtil.getRowValuesCount(rowId);
231 
232         return returnValue;
233     }
234 
235     public static JSONObject getValue(long valueId)
236         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
237             com.liferay.portal.PortalException {
238         com.liferay.portlet.expando.model.ExpandoValue returnValue = ExpandoValueServiceUtil.getValue(valueId);
239 
240         return ExpandoValueJSONSerializer.toJSONObject(returnValue);
241     }
242 
243     public static JSONObject getValue(long columnId, long rowId)
244         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
245             com.liferay.portal.PortalException {
246         com.liferay.portlet.expando.model.ExpandoValue returnValue = ExpandoValueServiceUtil.getValue(columnId,
247                 rowId);
248 
249         return ExpandoValueJSONSerializer.toJSONObject(returnValue);
250     }
251 
252     public static JSONObject getValue(java.lang.String className,
253         java.lang.String tableName, java.lang.String name, long rowId)
254         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
255             com.liferay.portal.PortalException {
256         com.liferay.portlet.expando.model.ExpandoValue returnValue = ExpandoValueServiceUtil.getValue(className,
257                 tableName, name, rowId);
258 
259         return ExpandoValueJSONSerializer.toJSONObject(returnValue);
260     }
261 
262     public static JSONObject getValue(long classNameId,
263         java.lang.String tableName, java.lang.String name, long rowId)
264         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
265             com.liferay.portal.PortalException {
266         com.liferay.portlet.expando.model.ExpandoValue returnValue = ExpandoValueServiceUtil.getValue(classNameId,
267                 tableName, name, rowId);
268 
269         return ExpandoValueJSONSerializer.toJSONObject(returnValue);
270     }
271 }