001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.http;
022:
023: import com.liferay.portal.service.LayoutServiceUtil;
024:
025: import org.json.JSONObject;
026:
027: /**
028: * <a href="LayoutServiceJSON.java.html"><b><i>View Source</i></b></a>
029: *
030: * <p>
031: * ServiceBuilder generated this class. Modifications in this class will be
032: * overwritten the next time is generated.
033: * </p>
034: *
035: * <p>
036: * This class provides a JSON utility for the
037: * <code>com.liferay.portal.service.LayoutServiceUtil</code>
038: * service utility. The static methods of this class calls the same methods of
039: * the service utility. However, the signatures are different because it is
040: * difficult for JSON to support certain types.
041: * </p>
042: *
043: * <p>
044: * ServiceBuilder follows certain rules in translating the methods. For example,
045: * if the method in the service utility returns a <code>java.util.List</code>,
046: * that is translated to a <code>org.json.JSONArray</code>. If the method in the
047: * service utility returns a <code>com.liferay.portal.model.Layout</code>,
048: * that is translated to a <code>org.json.JSONObject</code>. Methods that JSON
049: * cannot safely use are skipped. The logic for the translation is encapsulated
050: * in <code>com.liferay.portal.service.http.LayoutJSONSerializer</code>.
051: * </p>
052: *
053: * <p>
054: * This allows you to call the the backend services directly from JavaScript.
055: * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
056: * reference of how that portlet uses the generated JavaScript in
057: * <code>portal-web/docroot/html/js/service.js</code> to call the backend
058: * services directly from JavaScript.
059: * </p>
060: *
061: * <p>
062: * The JSON utility is only generated for remote services.
063: * </p>
064: *
065: * @author Brian Wing Shun Chan
066: *
067: * @see com.liferay.portal.service.LayoutServiceUtil
068: * @see com.liferay.portal.service.http.LayoutJSONSerializer
069: *
070: */
071: public class LayoutServiceJSON {
072: public static JSONObject addLayout(long groupId,
073: boolean privateLayout, long parentLayoutId,
074: java.lang.String name, java.lang.String title,
075: java.lang.String description, java.lang.String type,
076: boolean hidden, java.lang.String friendlyURL)
077: throws java.rmi.RemoteException,
078: com.liferay.portal.SystemException,
079: com.liferay.portal.PortalException {
080: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
081: .addLayout(groupId, privateLayout, parentLayoutId,
082: name, title, description, type, hidden,
083: friendlyURL);
084:
085: return LayoutJSONSerializer.toJSONObject(returnValue);
086: }
087:
088: public static void deleteLayout(long plid)
089: throws java.rmi.RemoteException,
090: com.liferay.portal.SystemException,
091: com.liferay.portal.PortalException {
092: LayoutServiceUtil.deleteLayout(plid);
093: }
094:
095: public static void deleteLayout(long groupId,
096: boolean privateLayout, long layoutId)
097: throws java.rmi.RemoteException,
098: com.liferay.portal.SystemException,
099: com.liferay.portal.PortalException {
100: LayoutServiceUtil
101: .deleteLayout(groupId, privateLayout, layoutId);
102: }
103:
104: public static java.lang.String getLayoutName(long groupId,
105: boolean privateLayout, long layoutId,
106: java.lang.String languageId)
107: throws java.rmi.RemoteException,
108: com.liferay.portal.SystemException,
109: com.liferay.portal.PortalException {
110: java.lang.String returnValue = LayoutServiceUtil.getLayoutName(
111: groupId, privateLayout, layoutId, languageId);
112:
113: return returnValue;
114: }
115:
116: public static com.liferay.portal.model.LayoutReference[] getLayoutReferences(
117: long companyId, java.lang.String portletId,
118: java.lang.String prefsKey, java.lang.String prefsValue)
119: throws java.rmi.RemoteException,
120: com.liferay.portal.SystemException {
121: com.liferay.portal.model.LayoutReference[] returnValue = LayoutServiceUtil
122: .getLayoutReferences(companyId, portletId, prefsKey,
123: prefsValue);
124:
125: return returnValue;
126: }
127:
128: public static void setLayouts(long groupId, boolean privateLayout,
129: long parentLayoutId, long[] layoutIds)
130: throws java.rmi.RemoteException,
131: com.liferay.portal.SystemException,
132: com.liferay.portal.PortalException {
133: LayoutServiceUtil.setLayouts(groupId, privateLayout,
134: parentLayoutId, layoutIds);
135: }
136:
137: public static JSONObject updateLayout(long groupId,
138: boolean privateLayout, long layoutId,
139: java.lang.String typeSettings)
140: throws java.rmi.RemoteException,
141: com.liferay.portal.SystemException,
142: com.liferay.portal.PortalException {
143: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
144: .updateLayout(groupId, privateLayout, layoutId,
145: typeSettings);
146:
147: return LayoutJSONSerializer.toJSONObject(returnValue);
148: }
149:
150: public static JSONObject updateLookAndFeel(long groupId,
151: boolean privateLayout, long layoutId,
152: java.lang.String themeId, java.lang.String colorSchemeId,
153: java.lang.String css, boolean wapTheme)
154: throws java.rmi.RemoteException,
155: com.liferay.portal.SystemException,
156: com.liferay.portal.PortalException {
157: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
158: .updateLookAndFeel(groupId, privateLayout, layoutId,
159: themeId, colorSchemeId, css, wapTheme);
160:
161: return LayoutJSONSerializer.toJSONObject(returnValue);
162: }
163:
164: public static JSONObject updateName(long plid,
165: java.lang.String name, java.lang.String languageId)
166: throws java.rmi.RemoteException,
167: com.liferay.portal.SystemException,
168: com.liferay.portal.PortalException {
169: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
170: .updateName(plid, name, languageId);
171:
172: return LayoutJSONSerializer.toJSONObject(returnValue);
173: }
174:
175: public static JSONObject updateName(long groupId,
176: boolean privateLayout, long layoutId,
177: java.lang.String name, java.lang.String languageId)
178: throws java.rmi.RemoteException,
179: com.liferay.portal.SystemException,
180: com.liferay.portal.PortalException {
181: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
182: .updateName(groupId, privateLayout, layoutId, name,
183: languageId);
184:
185: return LayoutJSONSerializer.toJSONObject(returnValue);
186: }
187:
188: public static JSONObject updateParentLayoutId(long plid,
189: long parentPlid) throws java.rmi.RemoteException,
190: com.liferay.portal.SystemException,
191: com.liferay.portal.PortalException {
192: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
193: .updateParentLayoutId(plid, parentPlid);
194:
195: return LayoutJSONSerializer.toJSONObject(returnValue);
196: }
197:
198: public static JSONObject updateParentLayoutId(long groupId,
199: boolean privateLayout, long layoutId, long parentLayoutId)
200: throws java.rmi.RemoteException,
201: com.liferay.portal.SystemException,
202: com.liferay.portal.PortalException {
203: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
204: .updateParentLayoutId(groupId, privateLayout, layoutId,
205: parentLayoutId);
206:
207: return LayoutJSONSerializer.toJSONObject(returnValue);
208: }
209:
210: public static JSONObject updatePriority(long plid, int priority)
211: throws java.rmi.RemoteException,
212: com.liferay.portal.SystemException,
213: com.liferay.portal.PortalException {
214: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
215: .updatePriority(plid, priority);
216:
217: return LayoutJSONSerializer.toJSONObject(returnValue);
218: }
219:
220: public static JSONObject updatePriority(long groupId,
221: boolean privateLayout, long layoutId, int priority)
222: throws java.rmi.RemoteException,
223: com.liferay.portal.SystemException,
224: com.liferay.portal.PortalException {
225: com.liferay.portal.model.Layout returnValue = LayoutServiceUtil
226: .updatePriority(groupId, privateLayout, layoutId,
227: priority);
228:
229: return LayoutJSONSerializer.toJSONObject(returnValue);
230: }
231: }
|