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