001
014
015 package com.liferay.portlet.documentlibrary.service.http;
016
017 import com.liferay.portal.kernel.json.JSONArray;
018 import com.liferay.portal.kernel.json.JSONFactoryUtil;
019 import com.liferay.portal.kernel.json.JSONObject;
020 import com.liferay.portal.kernel.util.StringPool;
021
022 import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
023
024 import java.util.Date;
025 import java.util.List;
026
027
031 public class DLFileShortcutJSONSerializer {
032 public static JSONObject toJSONObject(DLFileShortcut model) {
033 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034
035 jsonObj.put("uuid", model.getUuid());
036 jsonObj.put("fileShortcutId", model.getFileShortcutId());
037 jsonObj.put("groupId", model.getGroupId());
038 jsonObj.put("companyId", model.getCompanyId());
039 jsonObj.put("userId", model.getUserId());
040 jsonObj.put("userName", model.getUserName());
041
042 Date createDate = model.getCreateDate();
043
044 String createDateJSON = StringPool.BLANK;
045
046 if (createDate != null) {
047 createDateJSON = String.valueOf(createDate.getTime());
048 }
049
050 jsonObj.put("createDate", createDateJSON);
051
052 Date modifiedDate = model.getModifiedDate();
053
054 String modifiedDateJSON = StringPool.BLANK;
055
056 if (modifiedDate != null) {
057 modifiedDateJSON = String.valueOf(modifiedDate.getTime());
058 }
059
060 jsonObj.put("modifiedDate", modifiedDateJSON);
061 jsonObj.put("folderId", model.getFolderId());
062 jsonObj.put("toFolderId", model.getToFolderId());
063 jsonObj.put("toName", model.getToName());
064 jsonObj.put("status", model.getStatus());
065 jsonObj.put("statusByUserId", model.getStatusByUserId());
066 jsonObj.put("statusByUserName", model.getStatusByUserName());
067
068 Date statusDate = model.getStatusDate();
069
070 String statusDateJSON = StringPool.BLANK;
071
072 if (statusDate != null) {
073 statusDateJSON = String.valueOf(statusDate.getTime());
074 }
075
076 jsonObj.put("statusDate", statusDateJSON);
077
078 return jsonObj;
079 }
080
081 public static JSONArray toJSONArray(
082 com.liferay.portlet.documentlibrary.model.DLFileShortcut[] models) {
083 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
084
085 for (DLFileShortcut model : models) {
086 jsonArray.put(toJSONObject(model));
087 }
088
089 return jsonArray;
090 }
091
092 public static JSONArray toJSONArray(
093 com.liferay.portlet.documentlibrary.model.DLFileShortcut[][] models) {
094 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
095
096 for (DLFileShortcut[] model : models) {
097 jsonArray.put(toJSONArray(model));
098 }
099
100 return jsonArray;
101 }
102
103 public static JSONArray toJSONArray(
104 List<com.liferay.portlet.documentlibrary.model.DLFileShortcut> models) {
105 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
106
107 for (DLFileShortcut model : models) {
108 jsonArray.put(toJSONObject(model));
109 }
110
111 return jsonArray;
112 }
113 }