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.ExpandoRowServiceUtil;
26  
27  import org.json.JSONArray;
28  import org.json.JSONObject;
29  
30  /**
31   * <a href="ExpandoRowServiceJSON.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.ExpandoRowServiceUtil</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.ExpandoRow</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.ExpandoRowJSONSerializer</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.ExpandoRowServiceUtil
71   * @see com.liferay.portlet.expando.service.http.ExpandoRowJSONSerializer
72   *
73   */
74  public class ExpandoRowServiceJSON {
75      public static JSONObject addRow(long tableId)
76          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
77              com.liferay.portal.PortalException {
78          com.liferay.portlet.expando.model.ExpandoRow returnValue = ExpandoRowServiceUtil.addRow(tableId);
79  
80          return ExpandoRowJSONSerializer.toJSONObject(returnValue);
81      }
82  
83      public static void deleteRow(long rowId)
84          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
85              com.liferay.portal.PortalException {
86          ExpandoRowServiceUtil.deleteRow(rowId);
87      }
88  
89      public static JSONArray getDefaultTableRows(java.lang.String className,
90          int begin, int end)
91          throws java.rmi.RemoteException, com.liferay.portal.SystemException {
92          java.util.List<com.liferay.portlet.expando.model.ExpandoRow> returnValue =
93              ExpandoRowServiceUtil.getDefaultTableRows(className, begin, end);
94  
95          return ExpandoRowJSONSerializer.toJSONArray(returnValue);
96      }
97  
98      public static JSONArray getDefaultTableRows(long classNameId, int begin,
99          int end)
100         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
101         java.util.List<com.liferay.portlet.expando.model.ExpandoRow> returnValue =
102             ExpandoRowServiceUtil.getDefaultTableRows(classNameId, begin, end);
103 
104         return ExpandoRowJSONSerializer.toJSONArray(returnValue);
105     }
106 
107     public static int getDefaultTableRowsCount(java.lang.String className)
108         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
109         int returnValue = ExpandoRowServiceUtil.getDefaultTableRowsCount(className);
110 
111         return returnValue;
112     }
113 
114     public static int getDefaultTableRowsCount(long classNameId)
115         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
116         int returnValue = ExpandoRowServiceUtil.getDefaultTableRowsCount(classNameId);
117 
118         return returnValue;
119     }
120 
121     public static JSONArray getRows(long tableId, int begin, int end)
122         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
123         java.util.List<com.liferay.portlet.expando.model.ExpandoRow> returnValue =
124             ExpandoRowServiceUtil.getRows(tableId, begin, end);
125 
126         return ExpandoRowJSONSerializer.toJSONArray(returnValue);
127     }
128 
129     public static JSONArray getRows(java.lang.String className,
130         java.lang.String tableName, int begin, int end)
131         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
132         java.util.List<com.liferay.portlet.expando.model.ExpandoRow> returnValue =
133             ExpandoRowServiceUtil.getRows(className, tableName, begin, end);
134 
135         return ExpandoRowJSONSerializer.toJSONArray(returnValue);
136     }
137 
138     public static JSONArray getRows(long classNameId,
139         java.lang.String tableName, int begin, int end)
140         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
141         java.util.List<com.liferay.portlet.expando.model.ExpandoRow> returnValue =
142             ExpandoRowServiceUtil.getRows(classNameId, tableName, begin, end);
143 
144         return ExpandoRowJSONSerializer.toJSONArray(returnValue);
145     }
146 
147     public static int getRowsCount(long tableId)
148         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
149         int returnValue = ExpandoRowServiceUtil.getRowsCount(tableId);
150 
151         return returnValue;
152     }
153 
154     public static int getRowsCount(java.lang.String className,
155         java.lang.String tableName)
156         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
157         int returnValue = ExpandoRowServiceUtil.getRowsCount(className,
158                 tableName);
159 
160         return returnValue;
161     }
162 
163     public static int getRowsCount(long classNameId, java.lang.String tableName)
164         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
165         int returnValue = ExpandoRowServiceUtil.getRowsCount(classNameId,
166                 tableName);
167 
168         return returnValue;
169     }
170 }