1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.http;
16  
17  import com.liferay.portal.kernel.json.JSONArray;
18  import com.liferay.portal.kernel.json.JSONFactoryUtil;
19  import com.liferay.portal.kernel.json.JSONObject;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.model.PasswordPolicy;
22  
23  import java.util.Date;
24  import java.util.List;
25  
26  /**
27   * <a href="PasswordPolicyJSONSerializer.java.html"><b><i>View Source</i></b></a>
28   *
29   * <p>
30   * ServiceBuilder generated this class. Modifications in this class will be
31   * overwritten the next time is generated.
32   * </p>
33   *
34   * <p>
35   * This class is used by {@link PasswordPolicyServiceJSON} to translate objects.
36   * </p>
37   *
38   * @author    Brian Wing Shun Chan
39   * @see       com.liferay.portal.service.http.PasswordPolicyServiceJSON
40   * @generated
41   */
42  public class PasswordPolicyJSONSerializer {
43      public static JSONObject toJSONObject(PasswordPolicy model) {
44          JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
45  
46          jsonObj.put("passwordPolicyId", model.getPasswordPolicyId());
47          jsonObj.put("companyId", model.getCompanyId());
48          jsonObj.put("userId", model.getUserId());
49          jsonObj.put("userName", model.getUserName());
50  
51          Date createDate = model.getCreateDate();
52  
53          String createDateJSON = StringPool.BLANK;
54  
55          if (createDate != null) {
56              createDateJSON = String.valueOf(createDate.getTime());
57          }
58  
59          jsonObj.put("createDate", createDateJSON);
60  
61          Date modifiedDate = model.getModifiedDate();
62  
63          String modifiedDateJSON = StringPool.BLANK;
64  
65          if (modifiedDate != null) {
66              modifiedDateJSON = String.valueOf(modifiedDate.getTime());
67          }
68  
69          jsonObj.put("modifiedDate", modifiedDateJSON);
70          jsonObj.put("defaultPolicy", model.getDefaultPolicy());
71          jsonObj.put("name", model.getName());
72          jsonObj.put("description", model.getDescription());
73          jsonObj.put("changeable", model.getChangeable());
74          jsonObj.put("changeRequired", model.getChangeRequired());
75          jsonObj.put("minAge", model.getMinAge());
76          jsonObj.put("checkSyntax", model.getCheckSyntax());
77          jsonObj.put("allowDictionaryWords", model.getAllowDictionaryWords());
78          jsonObj.put("minAlphanumeric", model.getMinAlphanumeric());
79          jsonObj.put("minLength", model.getMinLength());
80          jsonObj.put("minLowerCase", model.getMinLowerCase());
81          jsonObj.put("minNumbers", model.getMinNumbers());
82          jsonObj.put("minSymbols", model.getMinSymbols());
83          jsonObj.put("minUpperCase", model.getMinUpperCase());
84          jsonObj.put("history", model.getHistory());
85          jsonObj.put("historyCount", model.getHistoryCount());
86          jsonObj.put("expireable", model.getExpireable());
87          jsonObj.put("maxAge", model.getMaxAge());
88          jsonObj.put("warningTime", model.getWarningTime());
89          jsonObj.put("graceLimit", model.getGraceLimit());
90          jsonObj.put("lockout", model.getLockout());
91          jsonObj.put("maxFailure", model.getMaxFailure());
92          jsonObj.put("lockoutDuration", model.getLockoutDuration());
93          jsonObj.put("requireUnlock", model.getRequireUnlock());
94          jsonObj.put("resetFailureCount", model.getResetFailureCount());
95          jsonObj.put("resetTicketMaxAge", model.getResetTicketMaxAge());
96  
97          return jsonObj;
98      }
99  
100     public static JSONArray toJSONArray(
101         com.liferay.portal.model.PasswordPolicy[] models) {
102         JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
103 
104         for (PasswordPolicy model : models) {
105             jsonArray.put(toJSONObject(model));
106         }
107 
108         return jsonArray;
109     }
110 
111     public static JSONArray toJSONArray(
112         com.liferay.portal.model.PasswordPolicy[][] models) {
113         JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
114 
115         for (PasswordPolicy[] model : models) {
116             jsonArray.put(toJSONArray(model));
117         }
118 
119         return jsonArray;
120     }
121 
122     public static JSONArray toJSONArray(
123         List<com.liferay.portal.model.PasswordPolicy> models) {
124         JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
125 
126         for (PasswordPolicy model : models) {
127             jsonArray.put(toJSONObject(model));
128         }
129 
130         return jsonArray;
131     }
132 }