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.DLFileEntry;
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 DLFileEntryJSONSerializer {
032            public static JSONObject toJSONObject(DLFileEntry model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("fileEntryId", model.getFileEntryId());
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                    jsonObj.put("versionUserId", model.getVersionUserId());
042                    jsonObj.put("versionUserName", model.getVersionUserName());
043    
044                    Date createDate = model.getCreateDate();
045    
046                    String createDateJSON = StringPool.BLANK;
047    
048                    if (createDate != null) {
049                            createDateJSON = String.valueOf(createDate.getTime());
050                    }
051    
052                    jsonObj.put("createDate", createDateJSON);
053    
054                    Date modifiedDate = model.getModifiedDate();
055    
056                    String modifiedDateJSON = StringPool.BLANK;
057    
058                    if (modifiedDate != null) {
059                            modifiedDateJSON = String.valueOf(modifiedDate.getTime());
060                    }
061    
062                    jsonObj.put("modifiedDate", modifiedDateJSON);
063                    jsonObj.put("folderId", model.getFolderId());
064                    jsonObj.put("name", model.getName());
065                    jsonObj.put("extension", model.getExtension());
066                    jsonObj.put("title", model.getTitle());
067                    jsonObj.put("description", model.getDescription());
068                    jsonObj.put("extraSettings", model.getExtraSettings());
069                    jsonObj.put("version", model.getVersion());
070                    jsonObj.put("size", model.getSize());
071                    jsonObj.put("readCount", model.getReadCount());
072    
073                    return jsonObj;
074            }
075    
076            public static JSONArray toJSONArray(
077                    com.liferay.portlet.documentlibrary.model.DLFileEntry[] models) {
078                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
079    
080                    for (DLFileEntry model : models) {
081                            jsonArray.put(toJSONObject(model));
082                    }
083    
084                    return jsonArray;
085            }
086    
087            public static JSONArray toJSONArray(
088                    com.liferay.portlet.documentlibrary.model.DLFileEntry[][] models) {
089                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
090    
091                    for (DLFileEntry[] model : models) {
092                            jsonArray.put(toJSONArray(model));
093                    }
094    
095                    return jsonArray;
096            }
097    
098            public static JSONArray toJSONArray(
099                    List<com.liferay.portlet.documentlibrary.model.DLFileEntry> models) {
100                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
101    
102                    for (DLFileEntry model : models) {
103                            jsonArray.put(toJSONObject(model));
104                    }
105    
106                    return jsonArray;
107            }
108    }