001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }