001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.wiki.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.wiki.model.WikiPage;
023    
024    import java.util.Date;
025    import java.util.List;
026    
027    /**
028     * @author    Brian Wing Shun Chan
029     * @generated
030     */
031    public class WikiPageJSONSerializer {
032            public static JSONObject toJSONObject(WikiPage model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("pageId", model.getPageId());
037                    jsonObj.put("resourcePrimKey", model.getResourcePrimKey());
038                    jsonObj.put("groupId", model.getGroupId());
039                    jsonObj.put("companyId", model.getCompanyId());
040                    jsonObj.put("userId", model.getUserId());
041                    jsonObj.put("userName", model.getUserName());
042    
043                    Date createDate = model.getCreateDate();
044    
045                    String createDateJSON = StringPool.BLANK;
046    
047                    if (createDate != null) {
048                            createDateJSON = String.valueOf(createDate.getTime());
049                    }
050    
051                    jsonObj.put("createDate", createDateJSON);
052    
053                    Date modifiedDate = model.getModifiedDate();
054    
055                    String modifiedDateJSON = StringPool.BLANK;
056    
057                    if (modifiedDate != null) {
058                            modifiedDateJSON = String.valueOf(modifiedDate.getTime());
059                    }
060    
061                    jsonObj.put("modifiedDate", modifiedDateJSON);
062                    jsonObj.put("nodeId", model.getNodeId());
063                    jsonObj.put("title", model.getTitle());
064                    jsonObj.put("version", model.getVersion());
065                    jsonObj.put("minorEdit", model.getMinorEdit());
066                    jsonObj.put("content", model.getContent());
067                    jsonObj.put("summary", model.getSummary());
068                    jsonObj.put("format", model.getFormat());
069                    jsonObj.put("head", model.getHead());
070                    jsonObj.put("parentTitle", model.getParentTitle());
071                    jsonObj.put("redirectTitle", model.getRedirectTitle());
072                    jsonObj.put("status", model.getStatus());
073                    jsonObj.put("statusByUserId", model.getStatusByUserId());
074                    jsonObj.put("statusByUserName", model.getStatusByUserName());
075    
076                    Date statusDate = model.getStatusDate();
077    
078                    String statusDateJSON = StringPool.BLANK;
079    
080                    if (statusDate != null) {
081                            statusDateJSON = String.valueOf(statusDate.getTime());
082                    }
083    
084                    jsonObj.put("statusDate", statusDateJSON);
085    
086                    return jsonObj;
087            }
088    
089            public static JSONArray toJSONArray(
090                    com.liferay.portlet.wiki.model.WikiPage[] models) {
091                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
092    
093                    for (WikiPage model : models) {
094                            jsonArray.put(toJSONObject(model));
095                    }
096    
097                    return jsonArray;
098            }
099    
100            public static JSONArray toJSONArray(
101                    com.liferay.portlet.wiki.model.WikiPage[][] models) {
102                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
103    
104                    for (WikiPage[] model : models) {
105                            jsonArray.put(toJSONArray(model));
106                    }
107    
108                    return jsonArray;
109            }
110    
111            public static JSONArray toJSONArray(
112                    List<com.liferay.portlet.wiki.model.WikiPage> models) {
113                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
114    
115                    for (WikiPage model : models) {
116                            jsonArray.put(toJSONObject(model));
117                    }
118    
119                    return jsonArray;
120            }
121    }