001    /**
002     * Copyright (c) 2000-2012 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.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    import com.liferay.portal.model.PasswordPolicy;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing PasswordPolicy in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see PasswordPolicy
034     * @generated
035     */
036    public class PasswordPolicyCacheModel implements CacheModel<PasswordPolicy>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(67);
041    
042                    sb.append("{passwordPolicyId=");
043                    sb.append(passwordPolicyId);
044                    sb.append(", companyId=");
045                    sb.append(companyId);
046                    sb.append(", userId=");
047                    sb.append(userId);
048                    sb.append(", userName=");
049                    sb.append(userName);
050                    sb.append(", createDate=");
051                    sb.append(createDate);
052                    sb.append(", modifiedDate=");
053                    sb.append(modifiedDate);
054                    sb.append(", defaultPolicy=");
055                    sb.append(defaultPolicy);
056                    sb.append(", name=");
057                    sb.append(name);
058                    sb.append(", description=");
059                    sb.append(description);
060                    sb.append(", changeable=");
061                    sb.append(changeable);
062                    sb.append(", changeRequired=");
063                    sb.append(changeRequired);
064                    sb.append(", minAge=");
065                    sb.append(minAge);
066                    sb.append(", checkSyntax=");
067                    sb.append(checkSyntax);
068                    sb.append(", allowDictionaryWords=");
069                    sb.append(allowDictionaryWords);
070                    sb.append(", minAlphanumeric=");
071                    sb.append(minAlphanumeric);
072                    sb.append(", minLength=");
073                    sb.append(minLength);
074                    sb.append(", minLowerCase=");
075                    sb.append(minLowerCase);
076                    sb.append(", minNumbers=");
077                    sb.append(minNumbers);
078                    sb.append(", minSymbols=");
079                    sb.append(minSymbols);
080                    sb.append(", minUpperCase=");
081                    sb.append(minUpperCase);
082                    sb.append(", regex=");
083                    sb.append(regex);
084                    sb.append(", history=");
085                    sb.append(history);
086                    sb.append(", historyCount=");
087                    sb.append(historyCount);
088                    sb.append(", expireable=");
089                    sb.append(expireable);
090                    sb.append(", maxAge=");
091                    sb.append(maxAge);
092                    sb.append(", warningTime=");
093                    sb.append(warningTime);
094                    sb.append(", graceLimit=");
095                    sb.append(graceLimit);
096                    sb.append(", lockout=");
097                    sb.append(lockout);
098                    sb.append(", maxFailure=");
099                    sb.append(maxFailure);
100                    sb.append(", lockoutDuration=");
101                    sb.append(lockoutDuration);
102                    sb.append(", requireUnlock=");
103                    sb.append(requireUnlock);
104                    sb.append(", resetFailureCount=");
105                    sb.append(resetFailureCount);
106                    sb.append(", resetTicketMaxAge=");
107                    sb.append(resetTicketMaxAge);
108                    sb.append("}");
109    
110                    return sb.toString();
111            }
112    
113            public PasswordPolicy toEntityModel() {
114                    PasswordPolicyImpl passwordPolicyImpl = new PasswordPolicyImpl();
115    
116                    passwordPolicyImpl.setPasswordPolicyId(passwordPolicyId);
117                    passwordPolicyImpl.setCompanyId(companyId);
118                    passwordPolicyImpl.setUserId(userId);
119    
120                    if (userName == null) {
121                            passwordPolicyImpl.setUserName(StringPool.BLANK);
122                    }
123                    else {
124                            passwordPolicyImpl.setUserName(userName);
125                    }
126    
127                    if (createDate == Long.MIN_VALUE) {
128                            passwordPolicyImpl.setCreateDate(null);
129                    }
130                    else {
131                            passwordPolicyImpl.setCreateDate(new Date(createDate));
132                    }
133    
134                    if (modifiedDate == Long.MIN_VALUE) {
135                            passwordPolicyImpl.setModifiedDate(null);
136                    }
137                    else {
138                            passwordPolicyImpl.setModifiedDate(new Date(modifiedDate));
139                    }
140    
141                    passwordPolicyImpl.setDefaultPolicy(defaultPolicy);
142    
143                    if (name == null) {
144                            passwordPolicyImpl.setName(StringPool.BLANK);
145                    }
146                    else {
147                            passwordPolicyImpl.setName(name);
148                    }
149    
150                    if (description == null) {
151                            passwordPolicyImpl.setDescription(StringPool.BLANK);
152                    }
153                    else {
154                            passwordPolicyImpl.setDescription(description);
155                    }
156    
157                    passwordPolicyImpl.setChangeable(changeable);
158                    passwordPolicyImpl.setChangeRequired(changeRequired);
159                    passwordPolicyImpl.setMinAge(minAge);
160                    passwordPolicyImpl.setCheckSyntax(checkSyntax);
161                    passwordPolicyImpl.setAllowDictionaryWords(allowDictionaryWords);
162                    passwordPolicyImpl.setMinAlphanumeric(minAlphanumeric);
163                    passwordPolicyImpl.setMinLength(minLength);
164                    passwordPolicyImpl.setMinLowerCase(minLowerCase);
165                    passwordPolicyImpl.setMinNumbers(minNumbers);
166                    passwordPolicyImpl.setMinSymbols(minSymbols);
167                    passwordPolicyImpl.setMinUpperCase(minUpperCase);
168    
169                    if (regex == null) {
170                            passwordPolicyImpl.setRegex(StringPool.BLANK);
171                    }
172                    else {
173                            passwordPolicyImpl.setRegex(regex);
174                    }
175    
176                    passwordPolicyImpl.setHistory(history);
177                    passwordPolicyImpl.setHistoryCount(historyCount);
178                    passwordPolicyImpl.setExpireable(expireable);
179                    passwordPolicyImpl.setMaxAge(maxAge);
180                    passwordPolicyImpl.setWarningTime(warningTime);
181                    passwordPolicyImpl.setGraceLimit(graceLimit);
182                    passwordPolicyImpl.setLockout(lockout);
183                    passwordPolicyImpl.setMaxFailure(maxFailure);
184                    passwordPolicyImpl.setLockoutDuration(lockoutDuration);
185                    passwordPolicyImpl.setRequireUnlock(requireUnlock);
186                    passwordPolicyImpl.setResetFailureCount(resetFailureCount);
187                    passwordPolicyImpl.setResetTicketMaxAge(resetTicketMaxAge);
188    
189                    passwordPolicyImpl.resetOriginalValues();
190    
191                    return passwordPolicyImpl;
192            }
193    
194            public void readExternal(ObjectInput objectInput) throws IOException {
195                    passwordPolicyId = objectInput.readLong();
196                    companyId = objectInput.readLong();
197                    userId = objectInput.readLong();
198                    userName = objectInput.readUTF();
199                    createDate = objectInput.readLong();
200                    modifiedDate = objectInput.readLong();
201                    defaultPolicy = objectInput.readBoolean();
202                    name = objectInput.readUTF();
203                    description = objectInput.readUTF();
204                    changeable = objectInput.readBoolean();
205                    changeRequired = objectInput.readBoolean();
206                    minAge = objectInput.readLong();
207                    checkSyntax = objectInput.readBoolean();
208                    allowDictionaryWords = objectInput.readBoolean();
209                    minAlphanumeric = objectInput.readInt();
210                    minLength = objectInput.readInt();
211                    minLowerCase = objectInput.readInt();
212                    minNumbers = objectInput.readInt();
213                    minSymbols = objectInput.readInt();
214                    minUpperCase = objectInput.readInt();
215                    regex = objectInput.readUTF();
216                    history = objectInput.readBoolean();
217                    historyCount = objectInput.readInt();
218                    expireable = objectInput.readBoolean();
219                    maxAge = objectInput.readLong();
220                    warningTime = objectInput.readLong();
221                    graceLimit = objectInput.readInt();
222                    lockout = objectInput.readBoolean();
223                    maxFailure = objectInput.readInt();
224                    lockoutDuration = objectInput.readLong();
225                    requireUnlock = objectInput.readBoolean();
226                    resetFailureCount = objectInput.readLong();
227                    resetTicketMaxAge = objectInput.readLong();
228            }
229    
230            public void writeExternal(ObjectOutput objectOutput)
231                    throws IOException {
232                    objectOutput.writeLong(passwordPolicyId);
233                    objectOutput.writeLong(companyId);
234                    objectOutput.writeLong(userId);
235    
236                    if (userName == null) {
237                            objectOutput.writeUTF(StringPool.BLANK);
238                    }
239                    else {
240                            objectOutput.writeUTF(userName);
241                    }
242    
243                    objectOutput.writeLong(createDate);
244                    objectOutput.writeLong(modifiedDate);
245                    objectOutput.writeBoolean(defaultPolicy);
246    
247                    if (name == null) {
248                            objectOutput.writeUTF(StringPool.BLANK);
249                    }
250                    else {
251                            objectOutput.writeUTF(name);
252                    }
253    
254                    if (description == null) {
255                            objectOutput.writeUTF(StringPool.BLANK);
256                    }
257                    else {
258                            objectOutput.writeUTF(description);
259                    }
260    
261                    objectOutput.writeBoolean(changeable);
262                    objectOutput.writeBoolean(changeRequired);
263                    objectOutput.writeLong(minAge);
264                    objectOutput.writeBoolean(checkSyntax);
265                    objectOutput.writeBoolean(allowDictionaryWords);
266                    objectOutput.writeInt(minAlphanumeric);
267                    objectOutput.writeInt(minLength);
268                    objectOutput.writeInt(minLowerCase);
269                    objectOutput.writeInt(minNumbers);
270                    objectOutput.writeInt(minSymbols);
271                    objectOutput.writeInt(minUpperCase);
272    
273                    if (regex == null) {
274                            objectOutput.writeUTF(StringPool.BLANK);
275                    }
276                    else {
277                            objectOutput.writeUTF(regex);
278                    }
279    
280                    objectOutput.writeBoolean(history);
281                    objectOutput.writeInt(historyCount);
282                    objectOutput.writeBoolean(expireable);
283                    objectOutput.writeLong(maxAge);
284                    objectOutput.writeLong(warningTime);
285                    objectOutput.writeInt(graceLimit);
286                    objectOutput.writeBoolean(lockout);
287                    objectOutput.writeInt(maxFailure);
288                    objectOutput.writeLong(lockoutDuration);
289                    objectOutput.writeBoolean(requireUnlock);
290                    objectOutput.writeLong(resetFailureCount);
291                    objectOutput.writeLong(resetTicketMaxAge);
292            }
293    
294            public long passwordPolicyId;
295            public long companyId;
296            public long userId;
297            public String userName;
298            public long createDate;
299            public long modifiedDate;
300            public boolean defaultPolicy;
301            public String name;
302            public String description;
303            public boolean changeable;
304            public boolean changeRequired;
305            public long minAge;
306            public boolean checkSyntax;
307            public boolean allowDictionaryWords;
308            public int minAlphanumeric;
309            public int minLength;
310            public int minLowerCase;
311            public int minNumbers;
312            public int minSymbols;
313            public int minUpperCase;
314            public String regex;
315            public boolean history;
316            public int historyCount;
317            public boolean expireable;
318            public long maxAge;
319            public long warningTime;
320            public int graceLimit;
321            public boolean lockout;
322            public int maxFailure;
323            public long lockoutDuration;
324            public boolean requireUnlock;
325            public long resetFailureCount;
326            public long resetTicketMaxAge;
327    }