1   /**
2    * Copyright (c) 2000-2007 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.portal.service.http;
24  
25  import com.liferay.portal.service.LayoutServiceUtil;
26  
27  import org.json.JSONObject;
28  
29  /**
30   * <a href="LayoutServiceJSON.java.html"><b><i>View Source</i></b></a>
31   *
32   * <p>
33   * ServiceBuilder generated this class. Modifications in this class will be overwritten
34   * the next time is generated.
35   * </p>
36   *
37   * <p>
38   * This class provides a JSON utility for the <code>com.liferay.portal.service.LayoutServiceUtil</code>
39   * service utility. The static methods of this class calls the same methods of the
40   * service utility. However, the signatures are different because it is difficult
41   * for JSON to support certain types.
42   * </p>
43   *
44   * <p>
45   * ServiceBuilder follows certain rules in translating the methods. For example,
46   * if the method in the service utility returns a <code>java.util.List</code>, that
47   * is translated to a <code>org.json.JSONArray</code>. If the method in the service
48   * utility returns a <code>com.liferay.portal.model.Layout</code>, that is translated
49   * to a <code>org.json.JSONObject</code>. Methods that JSON cannot safely use are
50   * skipped. The logic for the translation is encapsulated in <code>com.liferay.portal.service.http.LayoutJSONSerializer</code>.
51   * </p>
52   *
53   * <p>
54   * This allows you to call the the backend services directly from JavaScript. See
55   * <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a reference
56   * of how that portlet uses the generated JavaScript in <code>portal-web/docroot/html/js/service.js</code>
57   * to call the backend services directly from JavaScript.
58   * </p>
59   *
60   * <p>
61   * The JSON utility is only generated for remote services.
62   * </p>
63   *
64   * @author Brian Wing Shun Chan
65   *
66   * @see com.liferay.portal.service.LayoutServiceUtil
67   * @see com.liferay.portal.service.http.LayoutJSONSerializer
68   *
69   */
70  public class LayoutServiceJSON {
71      public static JSONObject addLayout(long groupId, boolean privateLayout,
72          long parentLayoutId, java.lang.String name, java.lang.String title,
73          java.lang.String description, java.lang.String type, boolean hidden,
74          java.lang.String friendlyURL)
75          throws com.liferay.portal.SystemException, 
76              com.liferay.portal.PortalException, java.rmi.RemoteException {
77          com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.addLayout(groupId,
78                  privateLayout, parentLayoutId, name, title, description, type,
79                  hidden, friendlyURL);
80  
81          return LayoutJSONSerializer.toJSONObject(returnValue);
82      }
83  
84      public static void deleteLayout(long plid)
85          throws com.liferay.portal.SystemException, 
86              com.liferay.portal.PortalException, java.rmi.RemoteException {
87          LayoutServiceUtil.deleteLayout(plid);
88      }
89  
90      public static void deleteLayout(long groupId, boolean privateLayout,
91          long layoutId)
92          throws com.liferay.portal.SystemException, 
93              com.liferay.portal.PortalException, java.rmi.RemoteException {
94          LayoutServiceUtil.deleteLayout(groupId, privateLayout, layoutId);
95      }
96  
97      public static java.lang.String getLayoutName(long groupId,
98          boolean privateLayout, long layoutId, java.lang.String languageId)
99          throws com.liferay.portal.SystemException, 
100             com.liferay.portal.PortalException, java.rmi.RemoteException {
101         java.lang.String returnValue = LayoutServiceUtil.getLayoutName(groupId,
102                 privateLayout, layoutId, languageId);
103 
104         return returnValue;
105     }
106 
107     public static com.liferay.portal.model.LayoutReference[] getLayoutReferences(
108         long companyId, java.lang.String portletId, java.lang.String prefsKey,
109         java.lang.String prefsValue)
110         throws com.liferay.portal.SystemException, java.rmi.RemoteException {
111         com.liferay.portal.model.LayoutReference[] returnValue = LayoutServiceUtil.getLayoutReferences(companyId,
112                 portletId, prefsKey, prefsValue);
113 
114         return returnValue;
115     }
116 
117     public static void setLayouts(long groupId, boolean privateLayout,
118         long parentLayoutId, long[] layoutIds)
119         throws com.liferay.portal.SystemException, 
120             com.liferay.portal.PortalException, java.rmi.RemoteException {
121         LayoutServiceUtil.setLayouts(groupId, privateLayout, parentLayoutId,
122             layoutIds);
123     }
124 
125     public static JSONObject updateLayout(long groupId, boolean privateLayout,
126         long layoutId, long parentLayoutId, java.lang.String name,
127         java.lang.String title, java.lang.String languageId,
128         java.lang.String description, java.lang.String type, boolean hidden,
129         java.lang.String friendlyURL)
130         throws com.liferay.portal.SystemException, 
131             com.liferay.portal.PortalException, java.rmi.RemoteException {
132         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateLayout(groupId,
133                 privateLayout, layoutId, parentLayoutId, name, title,
134                 languageId, description, type, hidden, friendlyURL);
135 
136         return LayoutJSONSerializer.toJSONObject(returnValue);
137     }
138 
139     public static JSONObject updateLayout(long groupId, boolean privateLayout,
140         long layoutId, long parentLayoutId, java.lang.String name,
141         java.lang.String title, java.lang.String languageId,
142         java.lang.String description, java.lang.String type, boolean hidden,
143         java.lang.String friendlyURL, java.lang.Boolean iconImage,
144         byte[] iconBytes)
145         throws com.liferay.portal.SystemException, 
146             com.liferay.portal.PortalException, java.rmi.RemoteException {
147         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateLayout(groupId,
148                 privateLayout, layoutId, parentLayoutId, name, title,
149                 languageId, description, type, hidden, friendlyURL, iconImage,
150                 iconBytes);
151 
152         return LayoutJSONSerializer.toJSONObject(returnValue);
153     }
154 
155     public static JSONObject updateLayout(long groupId, boolean privateLayout,
156         long layoutId, java.lang.String typeSettings)
157         throws com.liferay.portal.SystemException, 
158             com.liferay.portal.PortalException, java.rmi.RemoteException {
159         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateLayout(groupId,
160                 privateLayout, layoutId, typeSettings);
161 
162         return LayoutJSONSerializer.toJSONObject(returnValue);
163     }
164 
165     public static JSONObject updateLookAndFeel(long groupId,
166         boolean privateLayout, long layoutId, java.lang.String themeId,
167         java.lang.String colorSchemeId, java.lang.String css, boolean wapTheme)
168         throws com.liferay.portal.SystemException, 
169             com.liferay.portal.PortalException, java.rmi.RemoteException {
170         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateLookAndFeel(groupId,
171                 privateLayout, layoutId, themeId, colorSchemeId, css, wapTheme);
172 
173         return LayoutJSONSerializer.toJSONObject(returnValue);
174     }
175 
176     public static JSONObject updateName(long plid, java.lang.String name,
177         java.lang.String languageId)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portal.PortalException, java.rmi.RemoteException {
180         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateName(plid,
181                 name, languageId);
182 
183         return LayoutJSONSerializer.toJSONObject(returnValue);
184     }
185 
186     public static JSONObject updateName(long groupId, boolean privateLayout,
187         long layoutId, java.lang.String name, java.lang.String languageId)
188         throws com.liferay.portal.SystemException, 
189             com.liferay.portal.PortalException, java.rmi.RemoteException {
190         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateName(groupId,
191                 privateLayout, layoutId, name, languageId);
192 
193         return LayoutJSONSerializer.toJSONObject(returnValue);
194     }
195 
196     public static JSONObject updateParentLayoutId(long plid, long parentPlid)
197         throws com.liferay.portal.SystemException, 
198             com.liferay.portal.PortalException, java.rmi.RemoteException {
199         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateParentLayoutId(plid,
200                 parentPlid);
201 
202         return LayoutJSONSerializer.toJSONObject(returnValue);
203     }
204 
205     public static JSONObject updateParentLayoutId(long groupId,
206         boolean privateLayout, long layoutId, long parentLayoutId)
207         throws com.liferay.portal.SystemException, 
208             com.liferay.portal.PortalException, java.rmi.RemoteException {
209         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updateParentLayoutId(groupId,
210                 privateLayout, layoutId, parentLayoutId);
211 
212         return LayoutJSONSerializer.toJSONObject(returnValue);
213     }
214 
215     public static JSONObject updatePriority(long plid, int priority)
216         throws com.liferay.portal.SystemException, 
217             com.liferay.portal.PortalException, java.rmi.RemoteException {
218         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updatePriority(plid,
219                 priority);
220 
221         return LayoutJSONSerializer.toJSONObject(returnValue);
222     }
223 
224     public static JSONObject updatePriority(long groupId,
225         boolean privateLayout, long layoutId, int priority)
226         throws com.liferay.portal.SystemException, 
227             com.liferay.portal.PortalException, java.rmi.RemoteException {
228         com.liferay.portal.model.Layout returnValue = LayoutServiceUtil.updatePriority(groupId,
229                 privateLayout, layoutId, priority);
230 
231         return LayoutJSONSerializer.toJSONObject(returnValue);
232     }
233 }