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.ExpandoTableServiceUtil;
26  
27  import org.json.JSONArray;
28  import org.json.JSONObject;
29  
30  /**
31   * <a href="ExpandoTableServiceJSON.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.ExpandoTableServiceUtil</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.ExpandoTable</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.ExpandoTableJSONSerializer</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.ExpandoTableServiceUtil
71   * @see com.liferay.portlet.expando.service.http.ExpandoTableJSONSerializer
72   *
73   */
74  public class ExpandoTableServiceJSON {
75      public static JSONObject addDefaultTable(java.lang.String className)
76          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
77              com.liferay.portal.PortalException {
78          com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.addDefaultTable(className);
79  
80          return ExpandoTableJSONSerializer.toJSONObject(returnValue);
81      }
82  
83      public static JSONObject addDefaultTable(long classNameId)
84          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
85              com.liferay.portal.PortalException {
86          com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.addDefaultTable(classNameId);
87  
88          return ExpandoTableJSONSerializer.toJSONObject(returnValue);
89      }
90  
91      public static JSONObject addTable(java.lang.String className,
92          java.lang.String name)
93          throws java.rmi.RemoteException, com.liferay.portal.SystemException,
94              com.liferay.portal.PortalException {
95          com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.addTable(className,
96                  name);
97  
98          return ExpandoTableJSONSerializer.toJSONObject(returnValue);
99      }
100 
101     public static JSONObject addTable(long classNameId, java.lang.String name)
102         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
103             com.liferay.portal.PortalException {
104         com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.addTable(classNameId,
105                 name);
106 
107         return ExpandoTableJSONSerializer.toJSONObject(returnValue);
108     }
109 
110     public static void deleteTable(long tableId)
111         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
112             com.liferay.portal.PortalException {
113         ExpandoTableServiceUtil.deleteTable(tableId);
114     }
115 
116     public static void deleteTable(java.lang.String className,
117         java.lang.String name)
118         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
119             com.liferay.portal.PortalException {
120         ExpandoTableServiceUtil.deleteTable(className, name);
121     }
122 
123     public static void deleteTable(long classNameId, java.lang.String name)
124         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
125             com.liferay.portal.PortalException {
126         ExpandoTableServiceUtil.deleteTable(classNameId, name);
127     }
128 
129     public static void deleteTables(java.lang.String className)
130         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
131             com.liferay.portal.PortalException {
132         ExpandoTableServiceUtil.deleteTables(className);
133     }
134 
135     public static void deleteTables(long classNameId)
136         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
137             com.liferay.portal.PortalException {
138         ExpandoTableServiceUtil.deleteTables(classNameId);
139     }
140 
141     public static JSONObject getDefaultTable(java.lang.String className)
142         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
143             com.liferay.portal.PortalException {
144         com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.getDefaultTable(className);
145 
146         return ExpandoTableJSONSerializer.toJSONObject(returnValue);
147     }
148 
149     public static JSONObject getDefaultTable(long classNameId)
150         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
151             com.liferay.portal.PortalException {
152         com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.getDefaultTable(classNameId);
153 
154         return ExpandoTableJSONSerializer.toJSONObject(returnValue);
155     }
156 
157     public static JSONObject getTable(long tableId)
158         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
159             com.liferay.portal.PortalException {
160         com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.getTable(tableId);
161 
162         return ExpandoTableJSONSerializer.toJSONObject(returnValue);
163     }
164 
165     public static JSONObject getTable(java.lang.String className,
166         java.lang.String name)
167         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
168             com.liferay.portal.PortalException {
169         com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.getTable(className,
170                 name);
171 
172         return ExpandoTableJSONSerializer.toJSONObject(returnValue);
173     }
174 
175     public static JSONObject getTable(long classNameId, java.lang.String name)
176         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
177             com.liferay.portal.PortalException {
178         com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.getTable(classNameId,
179                 name);
180 
181         return ExpandoTableJSONSerializer.toJSONObject(returnValue);
182     }
183 
184     public static JSONArray getTables(java.lang.String className)
185         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
186             com.liferay.portal.PortalException {
187         java.util.List<com.liferay.portlet.expando.model.ExpandoTable> returnValue =
188             ExpandoTableServiceUtil.getTables(className);
189 
190         return ExpandoTableJSONSerializer.toJSONArray(returnValue);
191     }
192 
193     public static JSONArray getTables(long classNameId)
194         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
195             com.liferay.portal.PortalException {
196         java.util.List<com.liferay.portlet.expando.model.ExpandoTable> returnValue =
197             ExpandoTableServiceUtil.getTables(classNameId);
198 
199         return ExpandoTableJSONSerializer.toJSONArray(returnValue);
200     }
201 
202     public static JSONObject updateTable(long tableId, java.lang.String name)
203         throws java.rmi.RemoteException, com.liferay.portal.SystemException,
204             com.liferay.portal.PortalException {
205         com.liferay.portlet.expando.model.ExpandoTable returnValue = ExpandoTableServiceUtil.updateTable(tableId,
206                 name);
207 
208         return ExpandoTableJSONSerializer.toJSONObject(returnValue);
209     }
210 }