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