1
14
15 package com.liferay.portal.service.http;
16
17 import com.liferay.portal.kernel.json.JSONArray;
18 import com.liferay.portal.kernel.json.JSONFactoryUtil;
19 import com.liferay.portal.kernel.json.JSONObject;
20 import com.liferay.portal.model.Layout;
21
22 import java.util.List;
23
24
40 public class LayoutJSONSerializer {
41 public static JSONObject toJSONObject(Layout model) {
42 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
43
44 jsonObj.put("plid", model.getPlid());
45 jsonObj.put("groupId", model.getGroupId());
46 jsonObj.put("companyId", model.getCompanyId());
47 jsonObj.put("privateLayout", model.getPrivateLayout());
48 jsonObj.put("layoutId", model.getLayoutId());
49 jsonObj.put("parentLayoutId", model.getParentLayoutId());
50 jsonObj.put("name", model.getName());
51 jsonObj.put("title", model.getTitle());
52 jsonObj.put("description", model.getDescription());
53 jsonObj.put("type", model.getType());
54 jsonObj.put("typeSettings", model.getTypeSettings());
55 jsonObj.put("hidden", model.getHidden());
56 jsonObj.put("friendlyURL", model.getFriendlyURL());
57 jsonObj.put("iconImage", model.getIconImage());
58 jsonObj.put("iconImageId", model.getIconImageId());
59 jsonObj.put("themeId", model.getThemeId());
60 jsonObj.put("colorSchemeId", model.getColorSchemeId());
61 jsonObj.put("wapThemeId", model.getWapThemeId());
62 jsonObj.put("wapColorSchemeId", model.getWapColorSchemeId());
63 jsonObj.put("css", model.getCss());
64 jsonObj.put("priority", model.getPriority());
65 jsonObj.put("dlFolderId", model.getDlFolderId());
66
67 return jsonObj;
68 }
69
70 public static JSONArray toJSONArray(
71 com.liferay.portal.model.Layout[] models) {
72 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
73
74 for (Layout model : models) {
75 jsonArray.put(toJSONObject(model));
76 }
77
78 return jsonArray;
79 }
80
81 public static JSONArray toJSONArray(
82 com.liferay.portal.model.Layout[][] models) {
83 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
84
85 for (Layout[] model : models) {
86 jsonArray.put(toJSONArray(model));
87 }
88
89 return jsonArray;
90 }
91
92 public static JSONArray toJSONArray(
93 List<com.liferay.portal.model.Layout> models) {
94 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
95
96 for (Layout model : models) {
97 jsonArray.put(toJSONObject(model));
98 }
99
100 return jsonArray;
101 }
102 }