1
14
15 package com.liferay.portlet.documentlibrary.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.kernel.util.StringPool;
21
22 import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
23
24 import java.util.Date;
25 import java.util.List;
26
27
43 public class DLFileShortcutJSONSerializer {
44 public static JSONObject toJSONObject(DLFileShortcut model) {
45 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
46
47 jsonObj.put("uuid", model.getUuid());
48 jsonObj.put("fileShortcutId", model.getFileShortcutId());
49 jsonObj.put("groupId", model.getGroupId());
50 jsonObj.put("companyId", model.getCompanyId());
51 jsonObj.put("userId", model.getUserId());
52 jsonObj.put("userName", model.getUserName());
53
54 Date createDate = model.getCreateDate();
55
56 String createDateJSON = StringPool.BLANK;
57
58 if (createDate != null) {
59 createDateJSON = String.valueOf(createDate.getTime());
60 }
61
62 jsonObj.put("createDate", createDateJSON);
63
64 Date modifiedDate = model.getModifiedDate();
65
66 String modifiedDateJSON = StringPool.BLANK;
67
68 if (modifiedDate != null) {
69 modifiedDateJSON = String.valueOf(modifiedDate.getTime());
70 }
71
72 jsonObj.put("modifiedDate", modifiedDateJSON);
73 jsonObj.put("folderId", model.getFolderId());
74 jsonObj.put("toFolderId", model.getToFolderId());
75 jsonObj.put("toName", model.getToName());
76 jsonObj.put("status", model.getStatus());
77 jsonObj.put("statusByUserId", model.getStatusByUserId());
78 jsonObj.put("statusByUserName", model.getStatusByUserName());
79
80 Date statusDate = model.getStatusDate();
81
82 String statusDateJSON = StringPool.BLANK;
83
84 if (statusDate != null) {
85 statusDateJSON = String.valueOf(statusDate.getTime());
86 }
87
88 jsonObj.put("statusDate", statusDateJSON);
89
90 return jsonObj;
91 }
92
93 public static JSONArray toJSONArray(
94 com.liferay.portlet.documentlibrary.model.DLFileShortcut[] models) {
95 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
96
97 for (DLFileShortcut model : models) {
98 jsonArray.put(toJSONObject(model));
99 }
100
101 return jsonArray;
102 }
103
104 public static JSONArray toJSONArray(
105 com.liferay.portlet.documentlibrary.model.DLFileShortcut[][] models) {
106 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
107
108 for (DLFileShortcut[] model : models) {
109 jsonArray.put(toJSONArray(model));
110 }
111
112 return jsonArray;
113 }
114
115 public static JSONArray toJSONArray(
116 List<com.liferay.portlet.documentlibrary.model.DLFileShortcut> models) {
117 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
118
119 for (DLFileShortcut model : models) {
120 jsonArray.put(toJSONObject(model));
121 }
122
123 return jsonArray;
124 }
125 }