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.PortletPreferences;
21
22 import java.util.List;
23
24
40 public class PortletPreferencesJSONSerializer {
41 public static JSONObject toJSONObject(PortletPreferences model) {
42 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
43
44 jsonObj.put("portletPreferencesId", model.getPortletPreferencesId());
45 jsonObj.put("ownerId", model.getOwnerId());
46 jsonObj.put("ownerType", model.getOwnerType());
47 jsonObj.put("plid", model.getPlid());
48 jsonObj.put("portletId", model.getPortletId());
49 jsonObj.put("preferences", model.getPreferences());
50
51 return jsonObj;
52 }
53
54 public static JSONArray toJSONArray(
55 com.liferay.portal.model.PortletPreferences[] models) {
56 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
57
58 for (PortletPreferences model : models) {
59 jsonArray.put(toJSONObject(model));
60 }
61
62 return jsonArray;
63 }
64
65 public static JSONArray toJSONArray(
66 com.liferay.portal.model.PortletPreferences[][] models) {
67 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
68
69 for (PortletPreferences[] model : models) {
70 jsonArray.put(toJSONArray(model));
71 }
72
73 return jsonArray;
74 }
75
76 public static JSONArray toJSONArray(
77 List<com.liferay.portal.model.PortletPreferences> models) {
78 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
79
80 for (PortletPreferences model : models) {
81 jsonArray.put(toJSONObject(model));
82 }
83
84 return jsonArray;
85 }
86 }