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.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.DLFolder;
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 DLFolderJSONSerializer {
032            public static JSONObject toJSONObject(DLFolder model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("folderId", model.getFolderId());
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("parentFolderId", model.getParentFolderId());
062                    jsonObj.put("name", model.getName());
063                    jsonObj.put("description", model.getDescription());
064    
065                    Date lastPostDate = model.getLastPostDate();
066    
067                    String lastPostDateJSON = StringPool.BLANK;
068    
069                    if (lastPostDate != null) {
070                            lastPostDateJSON = String.valueOf(lastPostDate.getTime());
071                    }
072    
073                    jsonObj.put("lastPostDate", lastPostDateJSON);
074    
075                    return jsonObj;
076            }
077    
078            public static JSONArray toJSONArray(
079                    com.liferay.portlet.documentlibrary.model.DLFolder[] models) {
080                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
081    
082                    for (DLFolder model : models) {
083                            jsonArray.put(toJSONObject(model));
084                    }
085    
086                    return jsonArray;
087            }
088    
089            public static JSONArray toJSONArray(
090                    com.liferay.portlet.documentlibrary.model.DLFolder[][] models) {
091                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
092    
093                    for (DLFolder[] model : models) {
094                            jsonArray.put(toJSONArray(model));
095                    }
096    
097                    return jsonArray;
098            }
099    
100            public static JSONArray toJSONArray(
101                    List<com.liferay.portlet.documentlibrary.model.DLFolder> models) {
102                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
103    
104                    for (DLFolder model : models) {
105                            jsonArray.put(toJSONObject(model));
106                    }
107    
108                    return jsonArray;
109            }
110    }