001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.http;
022:
023: import com.liferay.portal.model.PasswordPolicy;
024:
025: import com.liferay.util.JSONUtil;
026:
027: import org.json.JSONArray;
028: import org.json.JSONObject;
029:
030: import java.util.List;
031:
032: /**
033: * <a href="PasswordPolicyJSONSerializer.java.html"><b><i>View Source</i></b></a>
034: *
035: * <p>
036: * ServiceBuilder generated this class. Modifications in this class will be
037: * overwritten the next time is generated.
038: * </p>
039: *
040: * <p>
041: * This class is used by
042: * <code>com.liferay.portal.service.http.PasswordPolicyServiceJSON</code>
043: * to translate objects.
044: * </p>
045: *
046: * @author Brian Wing Shun Chan
047: *
048: * @see com.liferay.portal.service.http.PasswordPolicyServiceJSON
049: *
050: */
051: public class PasswordPolicyJSONSerializer {
052: public static JSONObject toJSONObject(PasswordPolicy model) {
053: JSONObject jsonObj = new JSONObject();
054:
055: JSONUtil.put(jsonObj, "passwordPolicyId", model
056: .getPasswordPolicyId());
057: JSONUtil.put(jsonObj, "companyId", model.getCompanyId());
058: JSONUtil.put(jsonObj, "userId", model.getUserId());
059: JSONUtil.put(jsonObj, "userName", model.getUserName());
060: JSONUtil.put(jsonObj, "createDate", model.getCreateDate());
061: JSONUtil.put(jsonObj, "modifiedDate", model.getModifiedDate());
062: JSONUtil
063: .put(jsonObj, "defaultPolicy", model.getDefaultPolicy());
064: JSONUtil.put(jsonObj, "name", model.getName());
065: JSONUtil.put(jsonObj, "description", model.getDescription());
066: JSONUtil.put(jsonObj, "changeable", model.getChangeable());
067: JSONUtil.put(jsonObj, "changeRequired", model
068: .getChangeRequired());
069: JSONUtil.put(jsonObj, "minAge", model.getMinAge());
070: JSONUtil.put(jsonObj, "checkSyntax", model.getCheckSyntax());
071: JSONUtil.put(jsonObj, "allowDictionaryWords", model
072: .getAllowDictionaryWords());
073: JSONUtil.put(jsonObj, "minLength", model.getMinLength());
074: JSONUtil.put(jsonObj, "history", model.getHistory());
075: JSONUtil.put(jsonObj, "historyCount", model.getHistoryCount());
076: JSONUtil.put(jsonObj, "expireable", model.getExpireable());
077: JSONUtil.put(jsonObj, "maxAge", model.getMaxAge());
078: JSONUtil.put(jsonObj, "warningTime", model.getWarningTime());
079: JSONUtil.put(jsonObj, "graceLimit", model.getGraceLimit());
080: JSONUtil.put(jsonObj, "lockout", model.getLockout());
081: JSONUtil.put(jsonObj, "maxFailure", model.getMaxFailure());
082: JSONUtil.put(jsonObj, "lockoutDuration", model
083: .getLockoutDuration());
084: JSONUtil
085: .put(jsonObj, "requireUnlock", model.getRequireUnlock());
086: JSONUtil.put(jsonObj, "resetFailureCount", model
087: .getResetFailureCount());
088:
089: return jsonObj;
090: }
091:
092: public static JSONArray toJSONArray(List models) {
093: JSONArray jsonArray = new JSONArray();
094:
095: for (int i = 0; i < models.size(); i++) {
096: PasswordPolicy model = (PasswordPolicy) models.get(i);
097:
098: jsonArray.put(toJSONObject(model));
099: }
100:
101: return jsonArray;
102: }
103: }
|