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.portal.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.model.Permission;
021    
022    import java.util.List;
023    
024    /**
025     * @author    Brian Wing Shun Chan
026     * @generated
027     */
028    public class PermissionJSONSerializer {
029            public static JSONObject toJSONObject(Permission model) {
030                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
031    
032                    jsonObj.put("permissionId", model.getPermissionId());
033                    jsonObj.put("companyId", model.getCompanyId());
034                    jsonObj.put("actionId", model.getActionId());
035                    jsonObj.put("resourceId", model.getResourceId());
036    
037                    return jsonObj;
038            }
039    
040            public static JSONArray toJSONArray(
041                    com.liferay.portal.model.Permission[] models) {
042                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
043    
044                    for (Permission model : models) {
045                            jsonArray.put(toJSONObject(model));
046                    }
047    
048                    return jsonArray;
049            }
050    
051            public static JSONArray toJSONArray(
052                    com.liferay.portal.model.Permission[][] models) {
053                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
054    
055                    for (Permission[] model : models) {
056                            jsonArray.put(toJSONArray(model));
057                    }
058    
059                    return jsonArray;
060            }
061    
062            public static JSONArray toJSONArray(
063                    List<com.liferay.portal.model.Permission> models) {
064                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
065    
066                    for (Permission model : models) {
067                            jsonArray.put(toJSONObject(model));
068                    }
069    
070                    return jsonArray;
071            }
072    }